Skip to content

Instantly share code, notes, and snippets.

@amityweb
Last active September 17, 2018 09:43
Show Gist options
  • Save amityweb/5658856 to your computer and use it in GitHub Desktop.
Save amityweb/5658856 to your computer and use it in GitHub Desktop.
AppleScript to Add Things task from Mail in Apple Mail Folder
on run
tell application "System Events"
set isThingsRunning to (count of (every process whose bundle identifier is "com.culturedcode.things")) > 0
set isMailRunning to (count of (every process whose bundle identifier is "com.apple.mail")) > 0
end tell
if isThingsRunning and isMailRunning then
tell application "Mail"
set _msgs_to_capture to (every message of mailbox "Follow Up" of account "Email")
repeat with eachMessage in _msgs_to_capture
set TheSubject to (subject of eachMessage)
set theFromName to (extract name from sender of eachMessage)
set theTitle to theFromName & " - " & TheSubject
set theNotes to the content of eachMessage
set message_uri_raw to "message://%3c" & message id of eachMessage & "%3e"
set message_uri to "[url=" & message_uri_raw & "]" & theTitle & "[/url]"
set theCombinedBody to message_uri & return & return & theNotes
tell application "Things"
set newToDo to make new to do with properties {name:theTitle, notes:theCombinedBody}
end tell
set background color of eachMessage to blue
move eachMessage to mailbox "Archive" of account "Email"
end repeat
set selected mailboxes of message viewer 1 to {mailbox "Archive"} of account "Email"
end tell
end if
end run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment