Posted on

Create a link to any email message in Apple Mail (Mac)

I just gave an interview on Brett Terpstra’s Systematic podcast, when this AppleScript I’ve written came up. It creates a link for any email you’ve selected in Mac Mail and puts it on the clipboard. You can then paste it into any notes field or document elsewhere—in most apps, it’ll automatically be treated as a link and clickable. Opening it takes you to the message. This is better than most systems of copying-and-pasting text, or forwarding email to other apps, because it’ll show you the message in its original context.

There are various tools to launch AppleScripts, but the easiest (which doesn’t require any additional software) is the Script Menu. Instructions here. Once it’s turned on, open the Script menu (right side of the menu bar) and choose Open Scripts Folder > Open User Scripts Folder. Create a folder there named “Applications”, then one inside it named “Mail”. Put this AppleScript in that folder—the script will only show up in the menu when Mail is the front application.

Select a message, choose the Get Message URL script, switch to any other app, and paste the clipboard into any text field. Done. Usually you’ll see something like this:

message://%3c32A1456C-B027-40C1-8147-AE462EB38BC4@jeffporten.com%3e

…but some apps (like Mac Calendar) interpret the link; Calendar shows “Show in Mail…” if you paste it into the URL field, which is really weird because you need a script like this one to get the link in the first place. You’d think Apple would have set that up as a Mail command by now. If the link isn’t clickable, almost always you can select it, right-click on it, and choose Open URL from the contextual menu.

Just now realizing I can’t post attachments here, so head over to my website to pick up the script. It’s free for anyone who’s bought the book.