Last active
August 29, 2015 14:14
-
-
Save ncarboni/e44e746a5716b48e14ea to your computer and use it in GitHub Desktop.
Applescript for automatically send message with Orange Flag to omnifocus (with link to the original message in note) and change the flag to Yellow
This file contains 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
on run | |
-- based on Hunter Hillegas' original script at https://github.com/HunterHillegas/OmniFocusMailFlags | |
-- and on David Timothy Duval https://gist.github.com/dtduval/7866363 | |
if application "Mail" is running then tell application "Mail" | |
set _msgs_to_capture to (every message of inbox whose flag index is 1) | |
repeat with eachMessage in _msgs_to_capture | |
set theStart to missing value | |
set theDue to missing value | |
set theOmniTask to missing value | |
set theTitle to the subject of eachMessage | |
set theNotes to the content of eachMessage | |
set theCombinedBody to "message://%3c" & message id of eachMessage & "%3e" | |
tell application "OmniFocus" | |
tell default document | |
set newTaskProps to {name:theTitle} | |
if theStart is not missing value then set newTaskProps to newTaskProps & {defer date:theStart} | |
if theDue is not missing value then set newTaskProps to newTaskProps & {due date:theDue} | |
if theCombinedBody is not missing value then set newTaskProps to newTaskProps & {note:theCombinedBody} | |
set newTask to make new inbox task with properties newTaskProps | |
end tell | |
end tell | |
set flag index of eachMessage to 2 | |
end repeat | |
end tell | |
end run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
edit 1: add the possibility to run the script only if mail is running (otherwise keyboard maestro would open the app all the time)