Skip to content

Instantly share code, notes, and snippets.

@dpinney
Created June 18, 2017 12:45
Show Gist options
  • Save dpinney/479ad73dd52a431a048e97bc617deaa3 to your computer and use it in GitHub Desktop.
Save dpinney/479ad73dd52a431a048e97bc617deaa3 to your computer and use it in GitHub Desktop.
Copy a URL to the clipboard that links to the current Mail.app message.
-- Copy a URL to the clipboard that links to the current Mail.app message.
-- Bonus: the URL will work on both iOS and macOS.
-- By David@Pinney.org on 18 June 2017
on run
tell application "Mail"
set s to selection
if (count of s) is not 1 then
display dialog "Please select exactly one message." buttons {"OK"}
return
else
set msg to item 1 of s
set msgUrl to "message://" & "%3c" & (message id of msg) & "%3e"
set the clipboard to msgUrl
display dialog "Message URL copied to clipboard." buttons {"OK"} default button 1
end if
end tell
end run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment