Direct linking to messages in Apple Mail on Mac

In an effort to optimize my to-do lists, by moving away from to-do lists and into a more GTD (Getting Things Done)-based system, I decided to give NirvanaHQ a try, their web based GTD app seems pretty nice and so far I’m happy with it.

There’s just one thing though, I still very often find myself leaving unread messages in my inbox in Apple Mail.app, because I need to take action on the e-mail. It’s too much a hassle to enter a new GTD task like “take action on this and that e-mail”, and then you have to go and search for the e-mail afterwards.

I needed a way to link to specific e-mails within Apple Mail on my Mac running OS X Lion, like you can do with Evernote (just right click on the note and “copy note link”).

Thanks to daringfireball.net, I found a way to do it. On the link you can read the entire story and some other ways to do it as well (in Mac OS X Leopard though), but what I decided to do, was create an AppleScript to take care of it for me, so I used the script provided by the link above, and here’s exactly how you do it:

Please note that my system is not in English, so I may get some of the specific names/terms wrong, but hopefully you understand what I mean / where to go, anyway.

1) First you need to enable the AppleScript icon in your menu bar, so you have easy access to the script. If you have already done that, you can skip to next step. Otherwise, launch Spotlight and search for “applescript” and launch the app it suggests, I believe it’s called “AppleScript Utility”. In the app, Go to settings (CMD + ,) and tick “show script menu in menu bar”.

Now you should see a paper-scroll’ish icon in the menu bar, looking a bit like an “S”.

2) In the AppleScript Utility, hit CMD+N to create a new script. Then simply copy/paste this code (from daringfireball.net, thanks!):

tell application "Mail"
 set _sel to get selection
 set _links to {}
 repeat with _msg in _sel
 set _messageURL to "message://%3c" & _msg's message id & "%3e"
 set end of _links to _messageURL
 end repeat
 set AppleScript's text item delimiters to return
 set the clipboard to (_links as string)
end tell

3) Now hit CMD+S to save, name it as you wish, I went for “Copy Message Link”. Then go to  ~/Library/Scripts/Applications and create a new folder called “Mail”, and save as script in that folder.

4) Open Apple Mail, select an e-mail. Then go to the “S”-icon (Apple Script icon) in the menu bar and you should see “Copy Message Link” at the very bottom. Hit it, and it will now copy the message link to your clipboard.

Here’s how the script above will make an Apple Mail message link:

message://%3c20120xxxx.223xxxx.36300@xxx-xx-xxx-xx-27.xxxxxxxx.amazonaws.com%3e

I x’ed out some imfornation, as you can see, but you catch my drift.

With that link, I can simply paste it into my tasks in NirvanaHQ and I’m able to click it and it will take me straight to that message in Apple Mail. Clever!  This should work in other apps as well, which supports the “message:”-linking.

4 thoughts on “Direct linking to messages in Apple Mail on Mac”

  1. I have never thought that direct linking is possible and I am not familiar with it until I have found the post…Anyway, thanks a lot!

    Reply
    • Probably because you’re a Windows user, and Apple Mail is for Mac, not Windows. Smells like an attempt of getting a do-follow back link from commenting, so no CommentLuv for you, sorry!

      Reply
  2. Wow!That sounds really amazing, I think I’m going to give it a try. Does it work under Snow Leopard? The script is really nice, clear and simple. Thanks for sharing this!

    Reply

Leave a Comment