Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

In Mail, when I've selected a message, I would like to have a shortcut to copy the message_id (see my previous question) to the clipboard.

How do I manage that? Applescript, I presume?

share|improve this question
add comment

2 Answers

up vote 4 down vote accepted

That's doable as well. Paste the text below into AppleScript Editor (find it simply with Spotlight by typing "Space AppleScriptEditor" and hitting the enter key when it's highlighted).

tell application "Mail"

    set theSelection to selection
    set theMessage to first item of theSelection
    set theUrl to "message://<" & message id of theMessage & ">"
    set the clipboard to theUrl

end tell

You can test this by pressing the run button in the editor (with a message selected in Mail). Once you're satisfied, save the script as "Copy Message URL to Clipboard" under either:

/Users/yourusername/Library/Scripts

or even better

/Library/Scripts/Mail Scripts

To save it to the Mail Scripts folder, first save it to your Desktop. Then open a Finder window and do G, type the path to the Mail Scripts Folder and hit enter to view that folder. Now drag your newly created script to that folder.

While you're in the AppleScript Editor, you probably want to go ahead and enable the AppleScript Menu for the toolbar so that you can find and run the script easily. To do this, open AppleScript-> Preferences (,) and check the box labeled "Show Script menu in menu bar". Now you'll be able to access the script easily from

Scripts menu -> Mail Scripts->Copy Message URL to Clipboard

Reference: Some of the AppleScript displayed above was snipped from a portion of this AskDifferent answer

share|improve this answer
1  
Thank you, you've been extremely helpful! –  Michiel de Mare Jun 28 '12 at 20:58
    
This one helped me too. Thank you! –  ephsmith Jun 28 '12 at 21:41
add comment

The correct script is:

tell application "Mail"

    set theSelection to selection
    set theMessage to first item of theSelection
    set theUrl to "message:%3C" & message id of theMessage & "%3E"
    set the clipboard to theUrl

end tell
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.