Automatically Creating Tasks From Email in Outlook

Please note: I am no longer using Windows nor Outlook, so unfortunately I cannot offer any help with problems you encounter using these scripts and techniques.

Over the last few days I have been redoing my GTD-under-Outlook setup, based on the instructions available in the ”GTD and Outlook” guide from DavidCo (I will write more about my setup later). One of the tricks the guide suggest is creating a mail rule on outgoing mail, which scans the message body for a special tag (/wf or *wf* are suggested) and automatically adds the message to the @WAITING FOR email folder.

This is a very nice idea, and I am a fan of automating things as much as possible, so it really strikes a cord with me. Unfortunately, I am not using a @WAITING FOR email folder, instead I have just my @WAITING FOR task category. As strange as it sounds, Outlook does not have an email filter rule for automatically creating a task from an outgoing or incoming email message. For incoming messages there is a rule for flagging the message for “Follow up”, which creates a “to do” item but not a Task in itself (this is very confusing). This would be fine except that Follow-Up items are not synchronized to Toodledo by the ToodleDoSync application, and hence not synchronized to my iPhone.

So, evidently I had to solve this, and here is how I did it.

I noticed that there is an email action for “running a script”. It turns out the “script” must be a subroutine written in VisualBasic for Applications (VBA) from inside Outlook. A Google search for ”outlook create task from email” yielded a few good hits, including this one. It does pretty much what I want, except that the text and attachments of the message are copied into the task body, which I don’t like because (1) most formatting from the original email is lost, and (2) in my testing, some messages with attachments produced VBA errors. So I modified it to just attach a copy of the original message into the task, which preserves both its formatting and attachments identically. I made the rule it so that the tasks are created based on incoming mail because I copy myself automatically on all messages I send (in fact I have disabled saving messages to the “Sent Items” folder), and this makes it possible to create tasks by emailing my Exchange account from other locations.

As a bonus, I modified the script so that any text you type after the /wf tag becomes the title of the newly-created task (if you don’t type anything, the subject of the email message is used). This makes it easier to give your @WAITING FOR items a good, descriptive title upfront.

So here are the detailed steps of what you need to do:

(these instructions are based on Outlook 2010 which is what I use, if you use 2007 or prior you’ll have to find by yourself where the different options and menus are, which shouldn’t be all that difficult)

  1. In the Developer tab, click on “Visual Basic”, which opens the VBA development environment, and unless you already have other macros installed, should give you a blank window. 
  2. Paste the code:
  3. The code includes both the “script” to use in an email rule (which receives the email message as argument) and a macro (without arguments) so that you can run it manually from the Macros menu (also in the Developer tab). Try it out - select an email message, choose the macro from the Macros menu, and check that a new task in the @WAITING FOR category is created, with the original message as an attachment. 
  4. If needed, modify the category to which the task is assigned (or leave it empty to create an uncategorized task). 
  5. The code by default adds the recipient of the message to the beginning of the task title, separated by a colon (of the form “recipient: subject”). This makes it easier to see pending items per person (and, if you use the 2Do iPhone app, it automatically groups entries by the text before the colon, which makes it even easier to process. If you don’t want this, modify the value of addRecipient to “False”.
  6. To ensure that the macros run correctly after restarting Outlook, you have to sign it digitally, following the instructions here: http://office.microsoft.com/en-us/outlook-help/digitally-sign-a-macro-project…. Create a self-signed certificate and use it for signing the macro package. I had to restart Outlook for the digital signature to take proper effect. 
  7. Create the rule that will invoke the new subroutine on appropriate incoming email message(to create a new rule open the Home tab, then the Rules menu, then “Manage Rules and Alerts”, create a blank rule for incoming messages, choose the appropriate criteria, and click on the underlined parts to define the parameters). These are the criteria I used: my rule operates on incoming mail from any of my accounts (so that only I can create Waiting For tasks for myself) and that contains “/wf” or “/*wf*/” in the body (in practice I always use /wf). I choose to automatically move the message to a local Outlook file (I have a pretty restrictive server quota), but you may want to skip this step. I also mark the message as read automatically, and of course I invoke the script created in the previous steps. 
  8. Test it out. Send a message to yourself that contains /wf in the body. What I do in practice is that I include the /wf at the end of the message, and make it 1-point font and white so it’s invisible to most people, but still detectable by the filter. After the message arrives you should see the new task appear in the appropriate category, containing the original message as an attachment. If you want to give the task a custom title instead of using the email subject, type it after the /wf, like this: “/wf Response about foo bar”. The email recipient will still be added when you specify a custom title, unless you have disabled it in the code (see step 5).

Of course, when using this to flag messages sent to other people, you need to make sure you either automatically cc yourself (if you have created the rule on incoming mail), or that you create it on outgoing mail. I have not tested this case, but the “run a script” option is there as well for outgoing messages, so I don’t see a reason why it should not work.

Have fun.