Here's a TextExpander snippet (well, two snippets) for titlecasing the clipboard contents:
(Two snippets are necessary because of a bug that appends a newline to the end of any JXA snippets. This will be fixed in TextExpander 5.0.1, but in 5.0 it's necessary.)
Now, when I type
xmsg, TextExpander will insert the message URL for the selected message in Mail.app into whatever application I'm working in.
Here's the TextExpander snippet, and here's the AppleScript:
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" return urlText end tell