Creating OmniFocus tasks from Outlook 2010 for Windows emails

I love OmniFocus.  It lets me make sense of the overlapping and nonlinear work/home responsibilities.  I hate Outlook 2011 for OS X.  It just sucks.

Outlook 2010 (running in a Windows VM, natch) is perfect for my workflow (I am being serious – stop laughing), but there is no integration with OmniFocus.1

So, I cobbled together an Outlook macro and an AppleScript attached to a Folder Action to export an email from Outlook 2010 in the Windows VM to a network drive and then import it into OmniFocus.

Here are the product versions that I have tested and am using this with (although it will probably work with earlier versions of the software):

  • Parallels 7.0 with Windows VM
  • Outlook 2010
  • OmniFocus 1.10

There are three parts to this solution.

Windows mapped network drive

Create a folder in OS X, and then map a drive letter in Windows to that folder.  This is used to pass emails between the Windows VM and OS X.

Outlook 2010 macro

Create the following macro in Outlook,2 which takes the currently selected emails and exports them to the folder you created in the first step.  I also put the macro in the second slot in the Quick Access Toolbar, which assigns it the keyboard shortcut Alt+2.3
Option Explicit
 'define the constant for saving
Const mypath = "U:\"

Sub SaveToOmniFocus()
     'the mail we want to process
    Dim objItem As Outlook.MailItem
     'question for saving, use subject to save
    Dim strPrompt As String, strname As String
     'variables for the replacement of illegal characters
    Dim sreplace As String, mychar As Variant, strdate As String
     'put active mail in this object holder
    Set objItem = Outlook.ActiveExplorer.Selection.Item(1)
     'check if it's an email ... need to take a closer look cause
     'gives an error when something else (contact, task) is selected
     'because objItem is defined as a mailitem and code errors out
     'saving does work, if you take care that a mailitem is selected
     'before executing this code
    If objItem.Class = olMail Then
         'check on subject
        If objItem.Subject <> vbNullString Then
            strname = objItem.Sender & " Re- " & objItem.Subject
            strname = objItem.Sender & " Re- " & "No_Subject"
        End If
        strdate = objItem.ReceivedTime
         'define the character that will replace illegal characters
        sreplace = "_"
         'create an array to loop through illegal characters (saves lines)
        For Each mychar In Array("/", "\", ":", "?", Chr(34), "<", ">", "¦")
             'do the replacement for each character that's illegal
            strname = Replace(strname, mychar, sreplace)
            strdate = Replace(strdate, mychar, sreplace)
        Next mychar
         'Prompt the user for confirmation
        strPrompt = "Are you sure you want to save the item?"
        'If MsgBox(strPrompt, vbYesNo + vbQuestion) = vbYes Then
            objItem.SaveAs mypath & strname & "--" & strdate & ".msg", olMSG
        '    MsgBox "You chose not to save."
        'End If
    End If
End Sub

OS X folder script

Copy the following script into a text file,4 and save it to your Folder Actions Scripts folder.5  Right click on the folder you created in the first step, select Folder Actions Settings, and associate the script you just saved with that folder.

property pEmbedFile : true (* if true, file will be embedded, if false, file will be linked *)
property pUseQuickEntry : true (* if true, Quick Entry window used and left open, if false, actions added directly to Inbox *)

on adding folder items to this_folder after receiving added_items
        repeat with i from 1 to number of items in added_items
            set this_item to item i of added_items
            tell application "Finder" to set file_name to (name of this_item)
            tell application "OmniFocus"
                if (pUseQuickEntry) then
                    tell quick entry

                        set NewTask to make new inbox task with properties {name:file_name}
                        tell the note of NewTask
                            make new file attachment with properties {file name:this_item, embedded:pEmbedFile}
                        end tell

                    end tell
                    tell front document

                        set NewTask to make new inbox task with properties {name:file_name}
                        tell the note of NewTask
                            make new file attachment with properties {file name:this_item, embedded:pEmbedFile}
                        end tell

                    end tell
                end if

            end tell
            tell application "Finder" to delete file this_item
        end repeat
    end try
end adding folder items to
Now when you press Alt+2, the currently selected email will be saved to the folder in the Windows VM, and the Folder Action will pick it up and import it into OmniFocus.6  There is a slight lag (1-2 seconds), but it works.
  1. There are two AppleScripts that people have created to send an Outlook 2011 message to OmniFocus’s inbox: one by veritrope and one by Ranier Burgstaller.  But even the fine work of these two individuals can’t make Outlook 2011 suck less.
  2. You may need to enable the Developer tab in the Outlook Ribbon.
  3. Based on this macro.
  4. Based on this script.
  5. /Users/<username>/Library/Scripts/Folder Action Scripts/.
  6. It also deletes the file, but you can change that behavior in the AppleScript.

Comments are closed.