I keep a daily journal, and I like to have links to email messages, my mail client is Mail.app on OSX. I can drag-and-drop links to my journal program (VoodooPad), but I would really prefer to copy and paste them, so I have a link that looks like message://%3C30533360.1931252053580.bla.bla.bla.

Is there an easy way to obtain a link in this format from Mail.app?

3 Answers 3


Based on splattne's response, and this macosxhints entry, I figured out how to do it. Now, it's just a matter of using something like Quicksilver of FastScripts to bind it to a keyboard shortcut.

tell application "Mail"
  set selectedMessages to selection
  set theMessage to item 1 of selectedMessages  
  set messageid to message id of theMessage
    -- Make URL (must use URL-encoded values for "<" and ">")
  set urlText to "message://" & "%3c" & messageid & "%3e"  
  set the clipboard to (urlText)     
end tell
  • 1
    This also works in OS X Mavericks where the drag & drop functionality seems to be hit & miss. Aug 26, 2013 at 9:51

If I correctly interpret your question, you could use a variation of the AppleScript in these blog posts:

  • That gets me most of the way there. However, I'm not sure how to specify "the mail message that is currently selected" in Applescript. Jul 19, 2009 at 4:02

Not an answer to the question that you already answered yourself, but just for the archives:

After one has saved a file from a website or an email message, one can use Get Info in Finder to find where a file came from. For an email attachment this shows the message Sender, Subject and the URL referring to that message.

Instead of Get Info, one can also use the command line to get the information:

mdls -name kMDItemWhereFroms <filename>

Using the open command such URL will make OS X activate the default application, just like it would activate TextEdit for a text file. For message: URLs, Mail.app will be launched to show the message (if it still exists).

Combined with some AppleScript from the comments at the link above:

on open these_items 
   set first_item to item 1 of these_items 
   set full_path to quoted form of POSIX path of first_item 

   set cmd to ¬ 
      "/usr/bin/mdls -name kMDItemWhereFroms " & ¬ 
      full_path & " | grep 'http:\\|https:\\|message:' | xargs open" 
   do shell script cmd 
end open

Paste the above AppleScript in Script Editor and save it as an Application, with option Run Only. Now, when dragging any file onto that application, the source will be opened, if applicable. I am certainly not an AppleScript expert, and the above does not do any error handling, it simply takes the first file when multiple files are dropped onto the application, and it does not support directories. But one gets the idea, I guess.

(The backslashes in http:\\ above are intentional, and should not read //. The script searches for http:, https: or message:. In other words: they are not intended to be a part of http://, but together form an escaped backslash, to escape the pipe-character in the grep command.)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .