You can try @MacSparky’s script with a little surgery to get rid of the Python stuff:
tell application "Mail"
set _msgs to selected messages of message viewer 0
if (_msgs is not equal to missing value) then
set _msg to first item of _msgs
return "message://%3C" & (message id of _msg) & "%3E"
end if
end tell
Differences between this and the @JKoopmans script:
- This one doesn’t put anything on the clipboard.
- This one returns a link to just the first selected message; the other returns links to all the selected messages.
Recall that the @MacSparky script was intended to be used inside a TextExpander snippet. That’s why it just returns the URL—TextExpander takes the output of a script and inserts it.