Markdown, Emails & LCP

Automatization is, most of the time, a personal matter. If the communication between two apps becomes widely used, it often indicates an issue with one of the parts. Knowing that, when Joe Kohlmann asked for a way to send markdown formatted emails from the clipboard, I couldn't just sit around and wait for a solution.

Drafts is not a great place to write anything with more than a few lines, specially if you compare with Scratch or Byword or anything with a markdown bar1.

So let's consider that you write a beautiful email in markdown in your favorite text editor and copy it to the clipboard. If you open Drafts in an empty document and try to activate an action, you'll get an error. You must paste the content first and that's two taps. As you know, I take taps very seriously.

What's the best app to create magic with the content of your clipboard? That's right, Launch Center Pro. We'll create a one-tap action to format a markdown email to html and send it with a few details.

We'll use two Launch Center Pro actions, one of them for short emails, with a single paragraph, which will hold recipients and the subject, besides the content of the email, and another for longer emails, with line breaks, which will hold only the recipients OR the subject plus the content. Let's begin with the LCP action for short emails:

drafts://x-callback-url/create?text={{[[clipboard]]}}&action=Markdown%20Short

This will create a Drafts document with the clipboard content and activate the rule Markdown Short, as it follows:

Markdown Short:

drafts://x-callback-url/create?text=[[line|3]]&action=Markdown%3A%20Copy%20to%20Clipboard&x-source=Drafts&x-success={{drafts://x-callback-url/create?text=[[line|1]]%0A[[line|2]]&action=Short%20Clipboard%20Mail&afterSuccess=Delete}}&afterSuccess=Delete

Beware of an inception of actions. This action will call the Markdown: Copy to Clipboard default action from Drafts, then it will create another document and activate our custom Short Clipboard Mail action.

Short Clipboard Mail:

launchpro-email://x-callback-url/?to=[[line|1]]&subject=[[line|2]]&body=[[clipboard]]

This last called action will trigger LCP again and place the first line as recipient, second line as subject and the clipboard as the email body. Yes, it works fast, Drafts never failed to call so many actions in a row. Poof, we're done. Next!

The aforementioned chain of actions rely on the recent [[line|#]] tag, so if our presumed text body has a single line break, it will be considered as a line and the following content as another. This is not really good since our Markdown: Copy to Clipboard action targets at the third line only. To solve this conundrum, we'll use our old friends [[title]] and [[body]]. First, add another action to LCP:

drafts://x-callback-url/create?text={{[[clipboard]]}}&action=Markdown%20Long

Afterwards, we'll begin with our chain of Drafts actions. You can assume how they work unless you skipped the whole article and just downloaded the actions (I don't mind if you do it though).

Markdown Long:

drafts://x-callback-url/create?text=[[body]]&action=Markdown%3A%20Copy%20to%20Clipboard&x-source=Drafts&x-success={{drafts://x-callback-url/create?text=[[title]]&action=Long%20Clipboard%20Mail&afterSuccess=Delete}}&afterSuccess=Delete

Long Clipboard Mail:

launchpro-email://x-callback-url/?to=[[draft]]&subject=&body=[[clipboard]]

This example has the [[title]] as the recipients, just because I find it easier to type a subject then a bunch of contacts, but if you'd prefer to have your subject there, just replace to from the Long Clipboard Mail action to subject. No, I won't do it for you. See ya next time.

UPDATE: If you decide to create an action with the [[title]] as subject instead of recipients, there's an easier way to do it with the mail actions from Drafts. Create the following Launch Center Pro action:

drafts://x-callback-url/create?text=[clipboard]&action=Markdown%20Email

And download this action: Markdown Email. It is a super simple mail action with content as [[body]], first line as subject and to be sent as markdown html.


  1. Drafts for iPad has a shortcut bar, just saying.