Simplicity Is Bliss

“Simplicity is the result of hard work, complexity the one of no work at all.”- Taking it easy in Business, Personal Productivity and Technology. 
« Back to blog

Adding Waiting For Mail to OmniFocus by AppleScript

I really like my @waiting list. It's a great place for me to see who all these fellows are that still owe me. But one of the problems I have is that most requests I make are based on emails I sent. Taking the extra effort to add a task for each email to OmniFocus feels very much like defeating the purpose of personal productivity. So I started to track eMail Waiting Fors separately in Mail.app using MailTags and a Smart Mailbox. I simply tag each email with a request with my "@Waiting" tag and regularly review the related Smart Mailbox.

But during reviews it is actually quite hard to link back the waiting for emails from Mail.app with the individual projects in OmniFocus. Consequently I have looked for an alternative way to automatically get "Waiting For" emails tracked inside of OmniFocus and came up with this AppleScript that does the job nicely and automated.

Script functionality

The script get invokes by an Mail.app outbox rule which uses MailTags to filter on those out going mails that have been tagged as "waiting for". It then takes the message and creates a task in the OmniFocus Inbox called "<email recipient> to come back re <email subject>". The text between the email recipient and the email subject can be configured easily in the script.

The script only looks at the 'To' recipients and ignores and 'CC' or 'BCC' recipients. If the mail is going out to multiple recipients (which can happen, but isn't ideal when delegating actions) it will only show the first recipient's name and will add "and x more" where x will be the number of additional recipients.

A reference link to the original message is posted to the task's note section. You can optionally configure if you like the entire email body to be posted into the task's notes section as well.

The task created in the OmniFocus Inbox gets also automatically associated with your OmniFocus "waiting for" context which you need to reference in the script configuration section.

Finally the script uses Growl, if installed and running, to notify you about the successful addition of the "Waiting For" task to OmniFocus.

Installation of the script

  1. You will require MailTags from Indev to later built the proper Mail.app outbox rule
  2. Download the script and copy it into your standard script directory, e.g. ~/Users/<your username>/Library/Scripts/
  3. Modify the script configuration based on your needs and setup
  4. Create a outbox rule in Mail.App that invokes the script if specific conditions, i.e. MailTags Keyword of the message is "@Waiting", are met

Customising the key parameters

Inside the script you can and very likely should change some configuration properties to match your requirements and setup.

  • property mailBody : true - You should change this setting to 'false' if you do not want the entire body text of the email to be pasted into the OmniFocus task's note section.
  • property MidFix : "to come back re" - Change this text to whatever you like to see in the task title between the email recipient's name and the email's subject.
  • property myWFContext : "Waiting" - This variable needs to exactly match the name of the context in OmniFocus that you'd like to use for "Waiting For" items, i.e. "Waiting".

Creating the outbox rule in Mail.app

Next you need to create a outbox rule in Mail.app that looks similar to the one below. Again MailTags will be required to perform this action.

WF-Outbox-Rule

You should be good to go and all the eMails you now tag with your "Waiting For" tag before sending them out will nicely get added to your OmniFocus Inbox.

Update: I modified the script so that message URL back link works and reveals the correct message within Mail.app

Loading mentions Retweet

Comments (11)

Oct 11, 2009
bpwhistler said...
Thanks for the great script for adding emails to my Waiting context in OmniFocus. I seem to be having some problems. It's not consistent anymore. It works when I send a test email to myself...but doesn't when I send to somebody else. Any help would be greatly appreciated as I love this functionality.
Oct 11, 2009
Sven Fechner said...
Yep, I've recently got some feedback that script does not work in all cases. Let me go back and work on it again a bit. Will post an update here as soon as possible.
Oct 13, 2009
bpwhistler said...
Thanks...I love this script and use it extensively. I get frustrated when I don't see my Growl notification that it works!! :) Your script has made me lazy and content...
Oct 14, 2009
MP said...
Worked once for me and now doesn't work (OSX 10.5.8). MailTags 2.2. This error is appearing in console on invocation:-

15/10/09 9:18:26 AM /System/Library/CoreServices/AppleScript Runner.app/Contents/MacOS/AppleScript Runner[19161] CPSGetFrontProcess(): This call is deprecated and should not be called anymore.

Jan 26, 2010
Brian M. said...
My buddy and I both tried this and couldn't get this to work. Any tips? Common problems?
Jan 27, 2010
bpwhistler said...
The script has been working for me flawlessly since a recent Snow Leopard upgrade. It worked perfectly under Leopard, then had some glitches on Snow Leopard (first few releases and patches). Now under 10.6.2 it seems to be working flawlessly again. I don't know why you guys can't get it to work? I do know the developer moved away from OmniFocus awhile ago...and hasn't been updating the script. I don't know if he's back into OF again.
Jan 29, 2010
Sven Fechner said...
I am actually back on OmniFocus, but I do not use the script anymore. I went to a more manual style of processing, if you have read one of my latest posts. Anyways, I'll promise I'll have another look into the script and see if I can make it more stable or at least provide some debugging information. However, it won't be too soon and limited to 10.6.2 since I can't test on other OS X releases.
Jan 29, 2010
bpwhistler said...
Hi Sven...still loving the script. Glad to hear you're back to OF. As to the script...after the 10.6.2 update and updates in Mail...the script works flawlessly for me again. No tweaking necessary in my opinion.

I'm still trying to "tweak" a similar script that opens a blank email in Mail with the title of the action you run the script on from OF as the subject of the email. The script completes the original task & creates a new task in OF (same subject...but with a "Waiting for reply" addendum). But I'm trying to add the link back to the email sent into the notes field of the new task created... modeled after your script. Thus far beyond my scripting capabilities.

Jan 29, 2010
Sven Fechner said...
You may run into a problem there with your script as outgoing mails in Mail.app can only reference by URL once they are either saved or sent. In your case you script will loose track of the email as it can only can get as far as creating the mail with the task title, check off the task in OF and create the new one. It won't get any reference back to email as it won't get saved or sent (assuming you want to write additional things into the mail body). So most of it sounds feasible and useful, but that one thing may get a bit tricky. Let me know if you find a solution.
Jan 30, 2010
David S said...
Sven, I am very thankful that you might be revisiting this script as I could never get it to work (and I'm using 10.6.2). Thanks for the consideration!
Feb 03, 2010
bpwhistler said...
"You may run into a problem there with your script as outgoing mails in Mail.app can only reference by URL once they are either saved or sent. In your case you script will loose track of the email as it can only can get as far as creating the mail with the task title, check off the task in OF and create the new one. It won't get any reference back to email as it won't get saved or sent (assuming you want to write additional things into the mail body). So most of it sounds feasible and useful, but that one thing may get a bit tricky. Let me know if you find a solution."

I'm toying with the idea to have the script create the email from the task (including the task name in the subject line and all the notes in the body), delete the task (rather than creating a new one), have "your" script also automatically insert @Waiting for MailTags, and then complete your script...returning a referenced task to OF with all the prior Task information present in the email.

The note field won't be pretty or organized...but everything will be there.

What do you think?

Leave a comment...

 
Got an account with one of these? Login here, or just enter your comment below.
Posterous-login    twitter