Linking to Mail Messages

When I was transitioning to digital planning, one of the pivotal moments was when I realized that I didn’t need to find one app that did everything—including syncing. I could focus on finding the apps that worked best for me for tasks, appointments, and daily notes, and let each play to their strengths.

I’ve written before on how to tie OmniFocus and Evernote together. By adding links to the tasks and project support notes, you can quickly jump back and forth. I’ve also found it useful to add links to relevant email messages. This keeps the email in Mail, and I can get to it from the relevant task and project, whether I’m on my phone, iPad, or Mac.

By integrating links to the right email messages, you can more easily get your Inbox to Zero, be more effective in your communication, and relax, knowing that the information will still be available when and where you need it.

Photo courtesy of ©Shutterstock/Gajus

You can put links to an email message:

  • In your task list. Do you keep emails in your inbox so you can reply when you’ve completed a task? Instead, archive the message or file it into a Waiting or Action folder and add the message’s URL to the notes field. When the task is complete, the original email is just a click away, and you can report your progress and findings.
  • In a project support note. Add a link to a relevant email thread to a project support note. Unfortunately, Evernote doesn’t recognize URLs that start with message:// as URLs, so you need to paste the bare URL itself into the note. Once it’s there however, you can click on it to get back to the message.
  • In an email to someone else. Because of the way that Mail generates the URL, the URL will work for anyone who has the original message—even somebody else! The first time I saw this, I was stunned. I had no idea this would work. It’s an elegant way to refer back to an earlier message in the thread, to another thread, or to follow up on an earlier email. It won’t always work, but if you can link back to a message, it’s neat alternative to quoting the email.

    Let me be clear: they have to have the original message. You’re not giving them access to your email on your computer, or on a server someplace. Their copy of Mail just looks up the message in what they already have. If they don’t have the message, it won’t work.

There are probably other useful things you can do with a link to a message, but that’s where I usually use them.

Mail doesn’t have a direct way to get a URL for a message, but it’s pretty easy to do with a little AppleScript.

To use this script:

  1. Launch Script Editor (AppleScript Editor prior to Yosemite) and open its preferences.
  2. Turn on Show Script menu in menu bar. This turns on the system-wide script menu. I’d also make sure that application scripts are shown at the top (the next option).
  3. Download Copy Message URL.scpt. Or copy and paste (or retype) it into Script Editor, since you have it up.
  4. Launch Mail.
  5. Under the Script menu, choose Open Scripts Folder > Open Mail Scripts Folder. (You can also go straight to ~/Library/Scripts/Applications/Mail in the Finder, but the menu item will create the folder for you if it doesn’t already exist.)
  6. Move Copy Message URL.scpt into the Mail scripts folder.

Now you can quickly get a link to any email message in Mail. Just select a message and select `Copy Message URL` from the Scripts menu. (The Scripts menu is the little scrolled piece of parchment towards the right hand side of your menu bar.)

The power of a digital planning system is in letting each tool specialize and do what it’s good at. Let Mail handle email, and let other apps handle tasks and reference materials. Message URLs will let the other tools in your system integrate with Mail so it can extend your system.

Question: These are the three ways I typically use email message links. Where else would you put a link to an email message? Share your thoughts in the comments, or on Twitter, LinkedIn, or Facebook.

About

Colter writes software and blogs about personal growth and productivity. He lives in Silicon Valley (California) with his wife and children, recently took up golf, and watches mostly British TV shows.

Please note: I reserve the right to delete comments that are offensive or off-topic. For more information, see my comments policy.

  • Hello Colter,

    This is a useful script, thanks. It’s good practice to capture AppleScript’s text item delimiters at the beginning of the script and return them to that state after you have changed them, otherwise they will remain in that state until you restart the process running the AppleScript (the script editor, or the application – if the script is saved as an application). Also, not all of the script lines need to be within the ‘Tell Mail’ block as they’re standard AppleScript commands. I would rewrite your script as follows:

    try

    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”

    end repeat

    end tell

    set end of _links to _messageURL

    set _oldDelims to AppleScript’s text item delimiters — save delimiters current state

    set AppleScript’s text item delimiters to return

    set the clipboard to (_links as string)

    set AppleScript’s text item delimiters to _oldDelims — restore delimiters

    on error _errStr number _errorNumber

    set AppleScript’s text item delimiters to _oldDelims — restore delimiters in case something went wrong

    display dialog _errStr & ” Error code: ” & _errorNumber buttons {“OK”} — display the error

    end try

    • Thanks for calling me out, Damon. Yes, it’s good practice to preserve the text item delimiters. Nice error handling, too. I’ll update the script.

  • Hello Colter,

    I’ve found that message URLs don’t work on iOS if the message hasn’t been cached in the Mail app. If you file a message away in a stored folder (mailbox) and that folder hasn’t been loaded on the iOS device, tapping the URL doesn’t do anything. Therefore I’ve added some metadata to the script so you can at least see the context for the email if the message can’t viewed on iOS:

    — Script originally posted by Colter Reed
    http://colterreed.com/linking-to-mail-messages/

    try

    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 _Sender to _msg’s sender
    set _SendDate to _msg’s date sent
    set _ReceivedDate to _msg’s date received
    set _Subject to _msg’s subject
    end repeat
    end tell

    set end of _links to _messageURL & return & “Sender: ” & _Sender & return & “Sent: ” & _SendDate & return & “Received: ” & _ReceivedDate & return & “Subject: ” & _Subject
    set _oldDelims to AppleScript’s text item delimiters — save delimiters current state
    set AppleScript’s text item delimiters to return
    set the clipboard to (_links as string)
    set AppleScript’s text item delimiters to _oldDelims — restore delimiters

    on error _errStr number _errorNumber
    set AppleScript’s text item delimiters to _oldDelims — restore delimiters in case something went wrong
    display dialog _errStr & ” Error code: ” & _errorNumber buttons {“OK”} — display the error
    end try

    • That’s actually true for OS X, too. Mail has to have had a chance to cache the message. On OS X, we tend to leave Mail running in the background, so it has a chance to see everything as it comes in.

      • I hadn’t noticed that on OS X, although it will be much more prevalent on iOS. I’ve found, and correct me if I’m wrong, that Mail caches new emails after launch on OS X. It may take a while to perform if there are lots of new messages and then I see all emails appear in their relevant mailboxes.

        As you say, if I try to click a message URL while the caching is occurring, the URL will fail to open the message. With iOS Mail, unless you actually go into the folder (mailbox) that stores the filed message, iOS Mail will not cache the folder’s contents. At least that’s been my experience.

        Nevertheless, this is still very useful so thanks for posting.