View Single Post
Note: I haven't tested this on the final Leopard release, only on the final seed. There's been a report of problems under leopard. I'll leave it here, but recommend not running it under leopard final at this time.

I wrote this up a while ago so that I could sync my tasks into mail messages, organized on a one folder per context basis (context mail folders nested like contexts in your OmniFocus document). This was done so that I could access them on my iPhone on the go, without having to leave my laptop running with the OmniFocus web interface. Additionally this allows easy creation of new tasks from any context in mail from the iPhone.

I've been using it without any bad behavior for a while, so thought I'd post it here, but given that Leopard will make this irrelevant very soon (I hope... I have no inside info there, sorry) I'm mostly posting this for use as an example of OmniFocus Applescripting. It's more or less well documented in the script and I'd recommend just reviewing it for juicy tidbits.

WARNING: This works for me but it might not work for you. It might destroy data, it might chew on your IMAP account till it looks like an old POP3. Who knows. THERE IS NO SUPPORT FOR THIS. Please don't email support about this script if you use it. They will come down and pelt me with your email, printed out onto heavy weight paper. It hurts when they do that. If you want to trial this, I'd recommend setting up a test mail account on a server and pointing the script at that (done by changing a setting at the top of the script).

The file is too big as a forum attachment, so here's a URL:

http://ethanschoonover.com/files/tem...-mail-sync.zip

AGAIN: While this works, it's going to be pointless soon and I'd suggest just taking a look at the script for examples of how to do the things it does in OmniFocus (or mail for that matter). For the sake of completeness, however, here are installation and use instructions if you are crazy enough to try it.

Installation:
You can either run the script from script editor or just drop it into ~/Library/Scripts/Applications/OmniFocus/ and then add it to the OmniFocus toolbar or run it from the Scripts menu.

Use
Just running the script without any modification should location your "default" IMAP or .Mac account in Mail.app (the account can be specified in the script), create nested folders under a "master" @Context folder in that account, populate those folders with tasks from each context.

IF YOU HAVE A LOT OF TASKS (>150) IN YOUR CONTEXTS, THE INITIAL EMAIL SENDOUT WILL TAKE A LONG TIME. It's email. It's slow. It's not a good transport mechanism for tasks. Sigh.

I just run it once before I go to bed and once before I leave the office.

Complete tasks by moving them to your "!Done" folder (also created by the script). This can be done the iPhone.

Make new tasks in mail by replying to the "New Task" mails in each context folder (replying to an existing task should create a new task with both the context and project of the 'original' task). These are filed into the "!New" mail folder which you can ignore.

Tiger/Leopard
This was coded on Tiger but I'm using it on Leopard and it seems ok. The only weirdness I've seen is that the mail messages aren't created in hidden mode on Leopard. There are also some weird random occasional slowdowns checking mailboxes.

Growl Abuse
I have growl turned on for status messages. LOTS of stats messages. Lame, maybe. You can turn this off at the top of the script.

WARNING
It's slow. Usually it's been okay to force quit the script/app if it really hangs. It should recover gracefully on next run.

Functions
* Identify key accounts and values in Mail.app
* Locate or make top level context, done, and new folders in Mail.app
* Locate or make context rules+folders in Mail.app as necessary
* (UNIMPLEMENTED) Make non folder rules (check for replies, flag messages, etc.)
* Check "Done" folder, get IDs of all done tasks, mark them complete
* (UNIMPLEMENTED) Check New mailbox, get reply mails and process them into new tasks
* Make list of IDs of current available tasks, then cycle through all message tasks and remove those that are ghosts. during this, possibly compile list of remaining taskid-mod dates-mailmsgid+mailbox
* Empty mailboxes as necessary (currently just from the "Done" mailbox)
* (UNIMPLEMENTED) Send out "Make New" messages
* Send out all new tasks (skipping those that we've established are already in Mail,
either in the context folders or outbox)
-----------------------------------------------------------------------------------
NOTES
Uses Growl if it can, should fall back to dialogues if it can't.
Minimizes network traffic by doing as little emailing as possible. because sending email is slow, and i don't like slow.
Does not remove context folders in Mail that the user stops using, deletes, renames, in OmniFocus.

Last edited by Ethan Schoonover; 2007-10-28 at 10:06 AM..