This week's sponsor

Timing

Stop worrying about time and focus on doing your best work instead.


iOS 7 and Mail Message URLs

A feature of iOS 7 that I quickly described in my article and that I haven't seen mentioned in other places is the possibility to make Apple's Mail app open individual messages through a new message:// URL scheme. As I wrote:

In iOS 7, if you have a message URL that corresponds to a message, the URL will correctly open it directly in Mail. There are two limitations: the message has to be already downloaded in the Mail app, and, of course, you have to know the URL. So far, I haven’t found a way to create URLs to reference Mail messages on iOS, but the ones you create on your Mac through AppleScript and Mail.app will continue to work on iOS 7 devices. Therefore, if you have scripts that generate these URLs to, say, attach them to OmniFocus or Evernote, you’ll be able to tap them and open the associated message on an iPhone or iPad. I look forward to seeing whether developers will figure out a way to generate message:// URLs on iOS.

That wasn't the first time I covered message:// URLs on MacStories. In November 2012, I posted an AppleScript to quickly save a message's URL in Evernote for Mac with a hotkey; and even then, I was referencing a 2007 post by John Gruber on the topic:

The structure of these URLs is fairly simple: (1) the “message:” scheme, followed by (2) the message-id of the message, enclosed in angle brackets (“<” and “>”). The message-id is specified in each message’s “Message-ID” header field, which is part of the Internet email standard. Every message-id should be universally unique, and every message should have a message-id. In my testing, the only messages I could find that didn’t have Message-ID headers were spam; such messages cannot be referred to by Mail’s “message:” URLs.

The message:// URLs that Apple introduced in Leopard have gone mostly unchanged in terms of OS X integration throughout the years, proving to be a nice solution to reference specific messages in todo apps, note-taking apps, and so forth. Rather than searching for a message in Mail, you can generate a URL via AppleScript, archive it somewhere, and launch it (either by pasting it in Safari or right-clicking it in a Cocoa app) to open the referenced message in a separate Mail window -- no matter if the message has been archived, put in a folder, or left in the inbox.

Before iOS 7, the problem was that people who used those URLs to reference messages in, say, OmniFocus or Evernote would find them useless on an iPhone or iPad because iOS didn't know how to launch them. In iOS 7, if the message has already been fetched by the Mail app, you can launch a message:// URL and the specific message will come up. This means that if you're used to reference Mail messages in your favorite app, now you'll be able to tap message links in your favorite app's iOS version and they'll continue to work. Fantastico!

There are two ways (that I know of) to generate message URLs. The insane one is to manually construct one by copying a message ID in View > Message > All Headers (⇧⌘H) in the Mac's Mailapp and assembling the complete, encoded message URL. But, like I said, that's insane because it's an annoyingly long procedure.

AppleScript provides a much better solution. Here's a quick variation of my old AppleScript that saves a message's URL in Evernote as a new note, using the message's subject as note title.

Because the message's URL is saved as a clickable link, you can tap it in Evernote for iOS to open the Mail app directly in the referenced message. Note how the script also saves the message URL in Evernote's info screen (in a note, tap the "more..." button under the note title), which, however, won't launch the Mail app when tapped on iOS; you'll have to tap the inline, HTML link in the note for the system to work.

I haven't found a way to generate message URLs directly on iOS. Apple's Mail app certainly doesn't have a menu to generate these links, and Dispatch, which used to support them, has been updated to generate similar links, albeit in a proprietary format. On the Mac, AppleScript remains the fastest way to create message URLs from Apple's Mail app; you can integrate the script above with apps like Keyboard Maestro (see my macro here) to save URLs in Evernote, and, once you have the URLs, you should be able to save them for reference in apps that sync back to iOS, like OmniFocus, Reminders (albeit it doesn't let you tap URLs on iOS 7), or Fantastical.

Unlock MacStories Extras

Club MacStories offers exclusive access to extra MacStories content, delivered every week; it's also a way to support us directly.

Club MacStories will help you discover the best apps for your devices and get the most out of your iPhone, iPad, and Mac. Plus, it's made in Italy.

Starting at $5/month, with an annual option available. Join the Club.

A Club MacStories membership includes:

  • MacStories Weekly newsletter, delivered every week on Friday with app collections, tips, iOS workflows, and more;
  • Monthly Log newsletter, delivered once every month with behind-the-scenes stories, app notes, personal journals, and more;
  • Access to occasional giveaways, discounts, and free downloads.