The Omni Group Forums

The Omni Group Forums (http://forums.omnigroup.com/index.php)
-   OmniFocus for iPad (http://forums.omnigroup.com/forumdisplay.php?f=63)
-   -   iOS5 Killer addition > You can flag mails > You can script mail rule to add to OF :)) (http://forums.omnigroup.com/showthread.php?t=22418)

whpalmer4 2011-10-31 07:57 PM

Perhaps the Exchange server doesn't support marking a message as unread? Haven't ever used one, and intend to keep it that way :-)

Christian 2011-11-18 01:09 PM

Did any body find a good way to utilise the flagging of mail on iPad to trigger mail on mac to create a task from the flagged mail?

jdh 2011-11-19 06:06 AM

The only way to do this, unfortunately, would be to create a custom Applescript that runs on a scheduled basis (e.g. through launchd) to poll the mailbox looking for flagged messages to add to OmniFocus. As somebody else has already pointed out, Mail rules only trigger on [i]new[/i] mail as it's coming in, not on anything that's already in the Mail app (even marking messages as unread doesn't re-trigger the Mail rules).

I used to have a kludgy script that did this with an "Action" folder in an older version of Mail... Similar workflow in that I would move messages to the "Action" folder and then the script which ran every five minutes would pick up the message and add it to my OF inbox. I'm using Gmail rather than Mail.app these days and the script is probably buried in my backups somewhere now, but it wasn't a huge modification from the various Mail-to-OmniFocus scripts that can be found around the forums -- basically it just needs to be modified to search Mail instead of being trigger from a Mail rule.

Christian 2011-11-19 11:15 AM

Hmmm...unfortunately I still did not find the time to learn AppleScript...apple should build that function in...

nevwild 2012-01-03 03:24 PM

I found it!
 
I found the following script which takes flagged actions out of Apple Mail on your mac to your OF inbox. I have set it to run every 15 min via iCal

Full blog post can be found at [url]http://www.hanchorllc.com/2011/12/11/omnifocus-task-auto-import-via-ios-mail-flags/[/url]

script is as follows:

[CODE]on run

tell application "Mail"
repeat with _acct in imap accounts
--Look For Flagged Messages in the INBOX
set _acct_name to name of _acct
set _inbox to _acct's mailbox "INBOX"

set _msgs_to_capture to (a reference to ¬
(every message of _inbox ¬
whose flagged status is true))

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" & return & return & theNotes

tell application "OmniFocus"
tell default document
set newTaskProps to {name:theTitle}
if theStart is not missing value then set newTaskProps to newTaskProps & {start 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 flagged status of eachMessage to false

end repeat

end repeat
end tell

end run[/CODE]

stevenjohn 2012-01-03 06:22 PM

Great work :)) Will be trying this out!

emory 2012-08-07 09:24 AM

fyi an Exchange account in Mail.app will not work with this, as the IMAP Accounts account type will not return an Exchange account.

You must specify the account name and the Inbox name of 'Inbox' (not INBOX).


All times are GMT -8. The time now is 04:16 AM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.