in order to be work in Todoist, I needed to fully url encode the string (Todoist choked at the @ symbol):
tell application "Mail"
set theSelection to selection
set theMessage to first item of theSelection
set theUrl to "<" & message id of theMessage & ">"
set theUrl to do shell script "/usr/bin/python -c 'import sys, urllib; print urllib.quote(sys.argv[1])' " & quoted form of theUrl
set theUrl to "message://" & theUrl
set the clipboard to theUrl
end tell
- I saved the script to
/Library/Scripts/Mail Scripts
as suggested above - I installed also FastScript and bound the AppleScript to ⌘L (for Link)
now I can hit cmd-l on any message in Apple Mail and paste the link in todoist and clicking it opens the mail again, thanks internet!