Script: Mail/Copy URLs for Selected Messages

  • Script: Copy URLs for Selected Messages
  • Application: Mail
  • Suggested key binding: ⇧⌘C


mail = Appscript::app("Mail")
urls = { |msg| "message://" + CGI.escape("<#{msg.message_id.get}>") }
open('|pbcopy', 'w') { |io| io.write urls.join("\n") }

This script copies the URLs for the selected messages in Mail to the clipboard.

Mail URLs are local to your Mail library. When opened, they’ll launch Mail and open the message. They’re very useful when referring to Mail documents (i.e. emails) elsewhere, like in Things or Notational Velocity.

No, not all my scripts are about copying stuff to the clipboard, but hey, it’s sunday.

Get the standalone script file, or git pull if you’re keeping a git clone of the scripts.

This post of part of series on the scripts I use with FastScripts.

Got comments? Use reddit and/or poke me on twitter.