Skip to content

Instantly share code, notes, and snippets.

@bradwright
Last active August 25, 2016 19:05
Show Gist options
  • Save bradwright/9878155 to your computer and use it in GitHub Desktop.
Save bradwright/9878155 to your computer and use it in GitHub Desktop.
Take current Mail.app message, send its subject and 'message:<>' URL to OmniFocus, and then Archive the email
-- Send currently selected Mail.app message to OmniFocus 2 quick entry box, then archive it
-- Archive behaviour found at: http://vemedio.com/blog/posts/my-archive-email-apple-script
tell application "Mail"
set theSelectedMessages to selection
set the selected_message to item 1 ¬
of the theSelectedMessages
set message_id to the message id of the selected_message
set my_subject to the subject of the selected_message
set message_url to "message://%3c" & message_id & "%3e"
set _mb to mailbox of selected_message
set _acct to account of _mb
set _archive_box to _acct's mailbox "Archive"
tell application "OmniFocus"
tell quick entry
make new inbox task with properties {name:my_subject, note:message_url}
open
end tell
-- tab into subject pane
tell application "System Events"
keystroke tab
end tell
end tell
move selected_message to _archive_box
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment