Created
September 5, 2016 03:20
-
-
Save dblalock/afc656fd2fc568f0207ca1c153f3bb54 to your computer and use it in GitHub Desktop.
Creates markdown links to the currently selected Apple Mail messages and copies them to the clipboard
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--E.g., if you have a message selected that has subject and body: | |
-- Subj: Meeting about the Foo! | |
-- Body: whatever | |
--Running this script copies to the clipboard the string: | |
-- [Meeting about the Foo!](message://<some message id>) | |
--If you click on the resulting url, the message opens in Mail | |
-- | |
--Basically, this is for getting links to emails into a todo list / task manager | |
--based on https://www.macstories.net/tutorials/send-selected-mail-message-to-evernote-with-source-url/ | |
tell application "Mail" | |
activate | |
--get selected messages | |
set theSelection to selection | |
--loop through all selected messages | |
set output to "" | |
repeat with theMessage in theSelection | |
--get information from message | |
set theMessageDate to the date received of theMessage | |
set theMessageSender to sender of theMessage | |
set theMessageSubject to the subject of the theMessage | |
set theMessageContent to the content of theMessage | |
set theMessageURL to "message://%3c" & theMessage's message id & "%3e" | |
set theLink to "[" & theMessageSubject & "](" & theMessageURL & ")" | |
set output to output & theLink & " | |
" | |
end repeat | |
set the clipboard to output | |
end tell |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment