Outlook 2011 to OmniFocus

Shared By: Justin

Description

Mac users who have corporate IT people setting up their computers (or anyone who needs fuller Exchange support) often use Outlook 2011 (part of Microsoft’s Office:mac 2011 package) as their email application. Here’s an AppleScript for Outlook 2011 that lets you send items directly to my favorite task manger — OmniFocus for Mac!

This script will send any type of Outlook item/items (messages, tasks, notes, calendar items, and contacts) directly to OmniFocus’s Inbox — and even will make a new task item from a highlighted bit of text. If there is existing due date information associated with the item, that should also make the jump as well. And if you have GROWL installed, you’ll receive notifications that give you status updates as Items are added.

Attachments are also included in the new OmniFocus item — and you’ll even get vCard and vCal attachments where appropriate!

IMPORTANT NOTES AND REQUIREMENTS

Updated on April 13, 2012

  • This AppleScript requires Outlook 2011 SP1 or Greater (Version 14.1.0+)

  • For the final 1.0 release, I updated the script to use the newer GROWL app and attendee details if transferring a meeting.

  • Additional GROWL Notes: People with the older, non-App Store version of GROWL can try to do a quick Find-and-Replace on the script, substituting “GrowlHelperApp” for “Growl” wherever it appears in the notification portions of the script. I have also rewritten Growl code in an attempt to eliminate the errors that people get when it isn’t installed. (A big tip-of-the-hat goes to elasticthreads whose code inspired this alternate approach!) I’m looking for two types of feedback: 1.) Growl Users — Are you still getting notifications? 2.) Non-Growl Users — Are you still getting errors?

  • Did you recently update Outlook 2011 to SP2 and discover this AppleScript isn’t working anymore? That’s because the Microsoft is using a different directory. With SP1 it was using:

    ~/Documents/Microsoft User Data/Outlook Script Menu Items

    After upgrade to SP2, it is now using:

    ~/Library/Application Support/Microsoft/Office/Outlook Script Menu Items

    You can install a fresh version in the new location or just copy your scripts to the new location! (Thanks to Jim Dryfoos for pointing out the change!)

Installation Recommendations

Save this script to ~/Library/Application Support/Microsoft/Office/Outlook Script Menu Items (Or Its Equivalent in Localized Language). You can navigate quickly to this folder by selecting: Outlook’s Script Menu => About This Menu… => Open Folder).

Give it a filename that enables a keyboard shortcut to be used.

Example:
“Send to OmniFocus\mO.scpt” lets you press ⌘O to send items to OmniFocus!

Enjoy!

The Code

(*
Veritrope.com
Outlook 2011 to OmniFocus
Version 1.01
April 5, 2012

// TERMS OF USE:
This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/3.0/ or send a letter to Creative Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA.

// LIKE THIS SCRIPT?
If this AppleScript is helpful to you, please show your support here:
http://veritrope.com/support

// SCRIPT INFORMATION AND UPDATE PAGE
http://veritrope.com/code/outlook-2011-to-omnifocus

// REQUIREMENTS
THIS SCRIPT REQUIRES OUTLOOK 2011 SP1 OR GREATER!
More details on the script information page.

// CHANGELOG:
1.01  ADDED ORGANIZER INFO FOR MEETINGS
1.00  FINAL (UPDATED GROWL CODE)
1.00  BETA 1 - ASSORTED BUG FIXES
0.99  REVISED GROWL CODE
0.98  INITIAL RELEASE


// RECOMMENDED INSTALLATION INSTRUCTIONS:
1.) Save this script to ~/Documents/Microsoft User Data/Outlook Script Menu Items (Or Its Equivalent in Localized Language);
(You can navigate quickly to this folder by selecting:
 Outlook's Script Menu => About This Menu... => Open Folder)

2.) Give it a filename that enables a keyboard shortcut to be used.
   
Example:
Saving the script with the name "Send to OmniFocus\mO.scpt" lets you press ⌘O to send items to Evernote!

3.) Enjoy!
   
*)


(*
======================================
// PROPERTIES (USE CAUTION WHEN CHANGING)
======================================
*)


property successCount : 0
property growl_Running : "false"
property account_Type : "free"
property myTitle : "Item"
property theAttachments : ""
property thisMessage : ""
property itemNum : "0"
property attNum : "0"
property errNum : "0"
property errorText : ""
property the_class : ""
property list_Props : {}
property SaveLoc : ""
property NewTask : {}

(*
======================================
// MAIN PROGRAM
======================================
*)


--LET'S GO!
try
    --CHECK FOR GROWL
    my startGrowl()
   
    --SET UP ACTIVITIES
    set selectedItems to {}
   
    set selectedItems to my item_Check()
   
    --MESSAGES SELECTED?
    if selectedItems is not missing value then
       
        --GET FILE COUNT
        my item_Count(selectedItems, the_class)
       
        --ANNOUNCE THE EXPORT OF ITEMS
       
        my process_Items(itemNum, attNum, the_class)
       
        --PROCESS ITEMS FOR EXPORT
        my item_Process(selectedItems)
       
        --DELETE TEMP FOLDER IF IT EXISTS
        set success to my trashfolder(SaveLoc)
       
        --NO ITEMS SELECTED
    else
        set successCount to -1
    end if
   
    --GROWL RESULTS
    my growl_Growler(successCount, itemNum)
   
    -- ERROR HANDLING
on error errText number errNum
    tell application "System Events"
        set isGrlRunning to (count of (every process whose bundle identifier is "com.Growl.GrowlHelperApp")) > 0
    end tell
   
    ignoring application responses
        if isGrlRunning then
            if errNum is -128 then
                set part_1 to "tell application \"Growl\"
                "

                set part_2 to "notify with name ¬
                    \"Failure Notification\" title ¬
                    \"User Cancelled\" description \"User Cancelled\" application name ¬
                    \"Outlook to OmniFocus\"
                    end tell"

            else
                -- GROWL FAILURE FOR ERROR
                set part_2 to "notify with name ¬
                    \"Failure Notification\" title ¬
                    \"Import Failure\" description \"Failed to export due to the following error: \" & return & errText ¬
                    application name \"Outlook to OmniFocus\"
            end tell"

            end if
           
            -- NON-GROWL ERROR MSG. FOR ERROR
            display dialog "Item Failed to Import: " & errNum & return & errText with icon 0
        end if
    end ignoring
end try

(*
======================================
// PREPARATORY SUBROUTINES
======================================
*)


--APP DETECT
on appIsRunning(appName)
    tell application "System Events" to (name of processes) contains appName
end appIsRunning

--SET UP ACTIVITIES
on item_Check()
    --set myPath to (path to home folder)
    tell application "Microsoft Outlook"
        try -- GET MESSAGES
            set selectedItems to selection
            set raw_Class to (class of selectedItems)
            if raw_Class is list then
                set classList to {}
                repeat with selectedItem in selectedItems
                    copy class of selectedItem to end of classList
                end repeat
                if classList contains task then
                    set the_class to "Task"
                else
                    set raw_Class to (class of item 1 of selectedItems)
                end if
            end if
            if raw_Class is calendar event then set the_class to "Calendar"
            if raw_Class is note then set the_class to "Note"
            if raw_Class is task then set the_class to "Task"
            if raw_Class is contact then set the_class to "Contact"
            if raw_Class is incoming message then set the_class to "Message"
            if raw_Class is text then set the_class to "Text"
        end try
        return selectedItems
    end tell
end item_Check

--GET COUNT OF ITEMS AND ATTACHMENTS
on item_Count(selectedItems, the_class)
    tell application "Microsoft Outlook"
        if the_class is not "Text" then
            set itemNum to count of selectedItems
            set attNum to 0
            try
                repeat with selectedMessage in selectedItems
                    set attNum to attNum + (count of attachment of selectedMessage)
                end repeat
            end try
        else
            set itemNum to 1
        end if
    end tell
end item_Count

(*
======================================
// PROCESS OUTLOOK ITEMS SUBROUTINE
======================================
*)


on item_Process(selectedItems)
    tell application "Microsoft Outlook"
       
        --TEXT ITEM CLIP
        if (class of selectedItems) is text then
            set OFTitle to selectedItems
            set theContent to "Text Clipping from Outlook"
           
            --CREATE IN OMNIFOCUS
            tell application "OmniFocus"
                tell the first document
                    set NewTask to make new inbox task with properties {name:OFTitle, note:theContent}
                end tell
            end tell
           
            --ITEM HAS FINISHED -- COUNT IT AS A SUCCESS!
            set successCount to 1
        else
            --FULL ITEM EXPORT
            repeat with selectedItem in selectedItems
                set theProps to (properties of selectedItem)
                try
                    set theAttachments to attachments of selectedItem
                    set raw_Attendees to attendees of selectedItem
                end try
               
                --SET UP SOME VALUES
                set theCompletionDate to missing value
                set theStartDate to missing value
                set theDueDate to missing value
                set theFlag to false
               
                -- GET OUTLOOK ITEM INFORMATION
                set the_vCard to {}
               
                --WHAT KIND OF ITEM IS IT?
                if the_class is "Calendar" then
                   
                    (* // CALENDAR ITEM *)
                   
                    --PREPARE THE TEMPLATE 
                    --LEFT SIDE (FORM FIELDS)
                    set l_1 to "Event:  "
                    set l_2 to "Start Time:  "
                    set l_3 to "End Time:  "
                    set l_4 to "Location:  "
                    set l_5 to "Notes  :"
                   
                    --RIGHT SIDE (DATA FIELDS)
                    set r_1 to (subject of theProps)
                    set r_2 to (start time of theProps)
                    set r_3 to (end time of theProps)
                    set the_Location to (location of theProps)
                    if the_Location is missing value then set the_Location to "None"
                    set r_4 to the_Location
                   
                    --THE NOTES
                    set the_notes to ""
                    set item_Created to (current date)
                    try
                        set the_notes to (plain text content of theProps)
                    end try
                    if the_notes is missing value then set the_notes to ""
                   
                    --ADD ATTENDEE INFO IF IT'S A MEETING
                    if (count of raw_Attendees) > 0 then
                        set the_Organizer to "<strong>Organized By: </strong><br/>" & (organizer of selectedItem) & "<br/><br/>"
                        set the_Attendees to "Invited Attendees: " & return
                        repeat with raw_Attendee in raw_Attendees
                           
                            --GET ATTENDEE DATA
                            set raw_EmailAttendee to (email address of raw_Attendee)
                            set attend_Name to (name of raw_EmailAttendee) as text
                            set raw_Status to (status of raw_Attendee)
                           
                            --COERCE STATUS TO TEXT
                            if raw_Status contains not responded then
                                set attend_Status to "Not Responded"
                            else if raw_Status contains accepted then
                                set attend_Status to "Accepted"
                            else if raw_Status contains declined then
                                set attend_Status to "Declined"
                            else if raw_Status contains tentatively accepted then
                                set attend_Status to "Tentatively Accepted"
                            end if
                           
                            --COMPILE THE ATTENDEE DATA
                            set attend_String to attend_Name & " (" & attend_Status & ")" & return
                            set the_Attendees to the_Attendees & attend_String
                        end repeat
                        set the_notes to (the_Organizer & the_Attendees & the_notes)
                        set raw_Attendees to ""
                    end if
                   
                    --ASSEMBLE THE TEMPLATE
                    set theContent to l_1 & r_1 & return & l_2 & r_2 & return & l_3 & r_3 & return & l_4 & r_4 & return & return & return & return & the_notes & return & return
                   
                    --EXPORT VCARD DATA
                    try
                        set vcard_data to (icalendar data of theProps)
                        set vcard_extension to ".ics"
                        set the_vCard to my write_File(r_1, vcard_data, vcard_extension)
                    end try
                   
                    set OFTitle to r_1
                   
                    (* // NOTE ITEM *)
                else if the_class is "note" then
                   
                    --PREPARE THE TEMPLATE 
                    --LEFT SIDE (FORM FIELDS)
                    set l_1 to "Note:  "
                    set l_2 to "Creation Date:  "
                    set l_3 to "Category:  "
                    set l_4 to ""
                    set l_5 to "Notes:  "
                   
                    --RIGHT SIDE (DATA FIELDS)
                    set r_1 to name of theProps
                    set item_Created to creation date of theProps
                    set r_2 to (item_Created as text)
                   
                    --GET CATEGORY INFO
                    set the_Cats to (category of theProps)
                    set list_Cats to {}
                    set count_Cat to (count of the_Cats)
                    repeat with the_Cat in the_Cats
                        set cat_Name to (name of the_Cat as text)
                        copy cat_Name to the end of list_Cats
                        if count_Cat > 1 then
                            copy ", " to the end of list_Cats
                            set count_Cat to (count_Cat - 1)
                        else
                            set count_Cat to (count_Cat - 1)
                        end if
                    end repeat
                   
                    set r_3 to list_Cats
                    set r_4 to ""
                   
                    set item_Created to creation date of theProps
                   
                    --THE NOTES
                    try
                        set the_notes to plain text content of theProps
                    end try
                    if the_notes is missing value then set the_notes to ""
                   
                    --ASSEMBLE THE TEMPLATE
                    set theContent to l_1 & r_1 & return & l_2 & r_2 & return & l_3 & r_3 & return & l_4 & r_4 & return & return & return & return & the_notes & return & return
                   
                    --EXPORT VCARD DATA
                    set vcard_data to (icalendar data of theProps)
                    set vcard_extension to ".ics"
                    set the_vCard to my write_File(r_1, vcard_data, vcard_extension)
                   
                    set theHTML to true
                    set OFTitle to r_1
                   
                    (* // CONTACT ITEM *)
                else if the_class is "contact" then
                   
                    --PREPARE THE TEMPLATE 
                    --LEFT SIDE (FORM FIELDS)
                    set l_1 to "Name:  "
                    set l_2 to "Email:  "
                    set l_3 to "Phone Numbers:" & return
                    set l_4 to "Addresses:" & return
                    set l_5 to "Notes:"
                   
                    --GET EMAIL INFO
                    try
                        set list_Addresses to {}
                        set email_Items to (email addresses of theProps)
                        repeat with email_Item in email_Items
                            set the_Type to (type of email_Item as text)
                            set addr_Item to (address of email_Item) & " (" & my TITLECASE(the_Type) & ")" & return as text
                            copy addr_Item to the end of list_Addresses
                        end repeat
                    end try
                   
                    --GET PHONE INFO AND ENCODE TELEPHONE LINK
                    try
                        set list_Phone to {}
                        if business phone number of theProps is not missing value then
                            set b_Number to (business phone number of theProps)
                            set b_String to "-Work:  " & b_Number & return
                            copy b_String to end of list_Phone
                        end if
                        if home phone number of theProps is not missing value then
                            set h_Number to (home phone number of theProps)
                            set h_String to "-Home:  " & h_Number & return
                            copy h_String to end of list_Phone
                        end if
                        if mobile number of theProps is not missing value then
                            set m_Number to (mobile number of theProps)
                            set m_String to "-Mobile:  " & m_Number & return
                            copy m_String to end of list_Phone
                        end if
                    end try
                   
                    --GET ADDRESS INFO
                    try
                        set list_Addr to {}
                       
                        (*BUSINESS *)
                        if business street address of theProps is not missing value then
                            set b_Str to (business street address of theProps)
                            set b_gStr to my encodedURL(b_Str)
                            if (business city of theProps) is not missing value then
                                set b_Cit to (business city of theProps)
                                set b_gCit to my encodedURL(b_Cit)
                            else
                                set b_Cit to ""
                                set b_gCit to ""
                            end if
                            if (business state of theProps) is not missing value then
                                set b_Sta to (business state of theProps)
                                set b_gSta to my encodedURL(b_Sta)
                            else
                                set b_Sta to ""
                                set b_gSta to ""
                            end if
                            if (business zip of theProps) is not missing value then
                                set b_Zip to (business zip of theProps)
                                set b_gZip to my encodedURL(b_Zip)
                            else
                                set b_Zip to ""
                                set b_gZip to ""
                            end if
                            if (business country of theProps) is not missing value then
                                set b_Cou to (business country of theProps)
                                set b_gCou to my encodedURL(b_Cou)
                            else
                                set b_Cou to ""
                                set b_gCou to ""
                            end if
                            set b_Addr to b_Str & return & b_Cit & ", " & b_Sta & "  " & b_Zip & return & b_Cou
                           
                            --GOOGLE MAPS LOCATION IN URL
                            set b_gString to b_gStr & "," & b_gCit & "," & b_gSta & "," & b_gZip & "," & b_gCou
                            set b_GMAP to "http://maps.google.com/maps?q=" & b_gString
                            set b_String to "-Work: " & return & b_Addr & return & "(Link to Google Map:  " & b_GMAP & ")" & return
                            copy b_String to end of list_Addr
                        end if
                       
                        (*HOME *)
                        if home street address of theProps is not missing value then
                            set h_Str to (home street address of theProps)
                            set h_gStr to my encodedURL(h_Str)
                            if (home city of theProps) is not missing value then
                                set h_Cit to (home city of theProps)
                                set h_gCit to my encodedURL(h_Cit)
                            else
                                set h_Cit to ""
                                set h_gCit to ""
                            end if
                            if (home state of theProps) is not missing value then
                                set h_Sta to (home state of theProps)
                                set h_gSta to my encodedURL(h_Sta)
                            else
                                set h_Sta to ""
                                set h_gSta to ""
                            end if
                            if (home zip of theProps) is not missing value then
                                set h_Zip to (home zip of theProps)
                                set h_gZip to my encodedURL(h_Zip)
                            else
                                set h_Zip to ""
                                set h_gZip to ""
                            end if
                            if (home country of theProps) is not missing value then
                                set h_Cou to (home country of theProps)
                                set h_gCou to my encodedURL(h_Cou)
                            else
                                set h_Cou to ""
                                set h_gCou to ""
                            end if
                            set h_Addr to h_Str & return & h_Cit & ", " & h_Sta & "  " & h_Zip & return & h_Cou
                           
                            --GOOGLE MAPS LOCATION IN URL
                            set h_gString to h_gStr & "," & h_gCit & "," & h_gSta & "," & h_gZip & "," & h_gCou
                            set h_GMAP to "http://maps.google.com/maps?q=" & h_gString
                            set h_String to "-Home:  " & return & h_Addr & return & "(Link to Google Map:  " & h_GMAP & ")" & return
                            copy h_String to end of list_Addr
                        end if
                    end try
                   
                    --RIGHT SIDE (DATA FIELDS)
                    set r_1 to (display name of theProps)
                    set r_2 to (list_Addresses as string)
                    set r_3 to (list_Phone as text)
                    set r_4 to (list_Addr as text)
                   
                    --EXPORT VCARD DATA
                    set vcard_data to (vcard data of theProps)
                    set vcard_extension to ".vcf"
                    set item_Created to (current date)
                   
                    --THE NOTES
                    try
                        set the_notes to plain text note of theProps
                    end try
                    if the_notes is missing value then set the_notes to ""
                   
                    --ASSEMBLE THE TEMPLATE
                    set theContent to l_1 & r_1 & return & l_2 & r_2 & return & l_3 & r_3 & return & l_4 & r_4 & return & return & return & return & the_notes & return & return
                    set the_vCard to my write_File(r_1, vcard_data, vcard_extension)
                   
                    set OFTitle to r_1
                   
                    (* // TASK ITEM *)
                else if the_class is "Task" then
                   
                    --PREPARE THE TEMPLATE 
                    --LEFT SIDE (FORM FIELDS)
                    set l_1 to "Note:  "
                    set l_2 to "Priority:  "
                    set l_3 to "Due Date:  "
                    set l_4 to "Status:  "
                    set l_5 to "Notes:  "
                   
                    --RIGHT SIDE (DATA FIELDS)
                    set propClass to (class of theProps) as text
                    if propClass is "incoming message" then
                        set r_1 to (subject of theProps)
                    else
                        set r_1 to (name of theProps)
                    end if
                    set the_Priority to (priority of theProps)
                    if the_Priority is priority normal then set r_2 to "Normal"
                    if the_Priority is priority high then set r_2 to "High"
                    if the_Priority is priority low then set r_2 to "Low"
                   
                    set theDueDate to (due date of theProps)
                    set r_3 to theDueDate
                    set theCompletionDate to (completed date of theProps)
                    set theStartDate to (start date of theProps)
                    set item_Created to (current date)
                   
                    --TODO?
                    try
                        set todo_Flag to (todo flag of theProps) as text
                        set r_4 to my TITLECASE(todo_Flag)
                    end try
                   
                    --THE NOTES
                    try
                        set the_notes to plain text content of theProps
                    end try
                    if the_notes is missing value then set the_notes to ""
                   
                    --ASSEMBLE THE TEMPLATE
                    set theContent to l_1 & r_1 & return & l_2 & r_2 & return & l_3 & r_3 & return & l_4 & r_4 & return & return & return & return & the_notes & return & return
                   
                   
                    --EXPORT VCARD DATA
                    if propClass is not "incoming message" then
                        set vcard_extension to ".ics"
                        set vcard_data to (icalendar data of theProps)
                        set the_vCard to my write_File(r_1, vcard_data, vcard_extension)
                    end if
                   
                    set OFTitle to r_1
                   
                    (* // MESSAGE ITEM *)
                else
                   
                    --GET EMAIL INFO
                    set the_Sender to (sender of theProps)
                    set s_Name to (address of the_Sender)
                    set s_Address to (address of the_Sender)
                   
                    --REPLACE WITH NAME, IF AVAILABLE
                    try
                        set s_Name to (name of the_Sender)
                    end try
                   
                   
                    --GET CATEGORY INFO
                    set the_Cats to (category of theProps)
                    set list_Cats to {}
                    set count_Cat to (count of the_Cats)
                    repeat with the_Cat in the_Cats
                        set cat_Name to (name of the_Cat as text)
                        copy cat_Name to the end of list_Cats
                        if count_Cat > 1 then
                            copy ", " to the end of list_Cats
                            set count_Cat to (count_Cat - 1)
                        else
                            set count_Cat to (count_Cat - 1)
                        end if
                    end repeat
                   
                    --RIGHT SIDE (DATA FIELDS)
                    set m_Sub to (subject of theProps)
                    if m_Sub is missing value then
                        set r_2 to "<No Subject>"
                    else
                        set r_2 to {subject of theProps}
                    end if
                    set r_3 to (time sent of theProps)
                    set r_4 to list_Cats
                   
                    set theID to id of theProps as string
                    set item_Created to r_3
                    set OFTitle to r_2
                   
                    set theDueDate to (due date of theProps)
                    set theCompletionDate to (completed date of theProps)
                    set theStartDate to (start date of theProps)
                   
                    set oFlag to (todo flag of theProps) as text
                    if oFlag is "not completed" then
                        set theFlag to true
                    end if
                   
                    --PROCESS EMAIL CONTENT
                    set m_Content to plain text content of theProps
                    set theContent to "Name: " & s_Name & return & "Subject: " & r_2 & return & "Sent: " & r_3 & return & "Category: " & r_4 & return & return & return & return & m_Content & return & return
                end if
               
                --CREATE IN OMNIFOCUS
                tell application "OmniFocus"
                    tell the first document
                        set NewTask to make new inbox task with properties {name:OFTitle, note:theContent, flagged:theFlag, due date:theDueDate, completion date:theCompletionDate, start date:theStartDate}
                    end tell
                end tell
               
                --ATTACH VCARD (IF PRESENT)
                if the_vCard is not {} then my vCard_Attach(the_vCard, theProps, NewTask)
               
                --IF ATTACHMENTS PRESENT, RUN ATTACHMENT SUBROUTINE
                if theAttachments is not {} then my message_Attach(theAttachments, theProps, NewTask)
               
                --ITEM HAS FINISHED! COUNT IT AS A SUCCESS AND RESET ATTACHMENTS!
                set successCount to successCount + 1
                set theAttachments to {}
            end repeat
        end if
    end tell
end item_Process

(*
======================================
// UTILITY SUBROUTINES
======================================
*)


--URL ENCODE
on encodedURL(the_Word)
    set scpt to "php -r 'echo urlencode(\"" & the_Word & "\");'"
    return do shell script scpt
end encodedURL

--TITLECASE
on TITLECASE(txt)
    return do shell script "python -c \"import sys; print unicode(sys.argv[1], 'utf8').title().encode('utf8')\" " & quoted form of txt
end TITLECASE

--SORT SUBROUTINE
on simple_sort(my_list)
    set the index_list to {}
    set the sorted_list to {}
    repeat (the number of items in my_list) times
        set the low_item to ""
        repeat with i from 1 to (number of items in my_list)
            if i is not in the index_list then
                set this_item to item i of my_list as text
                if the low_item is "" then
                    set the low_item to this_item
                    set the low_item_index to i
                else if this_item comes before the low_item then
                    set the low_item to this_item
                    set the low_item_index to i
                end if
            end if
        end repeat
        set the end of sorted_list to the low_item
        set the end of the index_list to the low_item_index
    end repeat
    return the sorted_list
end simple_sort

--REPLACE
on replaceString(theString, theOriginalString, theNewString)
    set theNum to 0
    set {od, AppleScript's text item delimiters} to {AppleScript's text item delimiters, theOriginalString}
    set theStringParts to text items of theString
    if (count of theStringParts) is greater than 1 then
        set theString to text item 1 of theStringParts as string
        repeat with eachPart in items 2 thru -1 of theStringParts
            set theString to theString & theNewString & eachPart as string
            set theNum to theNum + 1
        end repeat
    end if
    set AppleScript's text item delimiters to od
    return theString
end replaceString


(*
======================================
// ATTACHMENT SUBROUTINES
=======================================
*)


--CLEAN TITLE FOR FILENAME
on clean_Title(rawFileName)
    set previousDelimiter to AppleScript's text item delimiters
    set potentialName to rawFileName
    set legalName to {}
    set illegalCharacters to {".", ",", "/", ":", "[", "]"}
    repeat with thisCharacter in the characters of potentialName
        set thisCharacter to thisCharacter as text
        if thisCharacter is not in illegalCharacters then
            set the end of legalName to thisCharacter
        else
            set the end of legalName to "_"
        end if
    end repeat
    return legalName
end clean_Title

--WRITE THE FILE
on write_File(r_1, vcard_data, vcard_extension)
    set ExportFolder to ((path to desktop folder) & "Temp Export From Outlook:") as string
    set SaveLoc to my f_exists(ExportFolder)
    set fileName to (my clean_Title(r_1) & vcard_extension)
    set theFileName to (ExportFolder & fileName)
    try
        open for access file theFileName with write permission
        write vcard_data to file theFileName as string
        close access file theFileName
        return theFileName
       
    on error errorMessage
        log errorMessage
        try
            close access file theFileName
        end try
    end try
end write_File

--FOLDER EXISTS
on f_exists(ExportFolder)
    try
        set myPath to (path to home folder)
        get ExportFolder as alias
        set SaveLoc to ExportFolder
    on error
        tell application "Finder" to make new folder with properties {name:"Temp Export From Outlook"}
    end try
end f_exists

--VCARD PROCESSING
on vCard_Attach(the_vCard, theProps, NewTask)
    tell application "OmniFocus"
        tell the note of NewTask
            make new file attachment with properties {file name:the_vCard, embedded:true}
        end tell
    end tell
end vCard_Attach

--ATTACHMENT PROCESSING
on message_Attach(theAttachments, theProps, NewTask)
    tell application "Microsoft Outlook"
        --MAKE SURE TEXT ITEM DELIMITERS ARE DEFAULT
        set AppleScript's text item delimiters to ""
       
        --TEMP FILES PROCESSED ON THE DESKTOP
        set ExportFolder to ((path to desktop folder) & "Temp Export From Outlook:") as string
        set SaveLoc to my f_exists(ExportFolder)
       
        --PROCESS THE ATTCHMENTS
        set attCount to 0
        repeat with theAttachment in theAttachments
            set theFileName to ExportFolder & theAttachment's name
            try
                save theAttachment in theFileName
            end try
            tell application "OmniFocus"
                tell the note of NewTask
                    make new file attachment with properties {file name:theFileName, embedded:true}
                end tell
            end tell
           
            --SILENT DELETE OF TEMP FILE
            set trash_Folder to path to trash folder from user domain
            do shell script "mv " & quoted form of POSIX path of theFileName & space & quoted form of POSIX path of trash_Folder
        end repeat
    end tell
end message_Attach

--SILENT DELETE OF TEMP FOLDER (THANKS MARTIN MICHEL!)
on trashfolder(SaveLoc)
    try
        set trashfolderpath to ((path to trash) as Unicode text)
        set srcfolderinfo to info for (SaveLoc as alias)
        set srcfoldername to name of srcfolderinfo
        set SaveLoc to (SaveLoc as alias)
        set SaveLoc to (quoted form of POSIX path of SaveLoc)
        set counter to 0
        repeat
            if counter is equal to 0 then
                set destfolderpath to trashfolderpath & srcfoldername & ":"
            else
                set destfolderpath to trashfolderpath & srcfoldername & " " & counter & ":"
            end if
            try
                set destfolderalias to destfolderpath as alias
            on error
                exit repeat
            end try
            set counter to counter + 1
        end repeat
        set destfolderpath to quoted form of POSIX path of destfolderpath
        set command to "ditto " & SaveLoc & space & destfolderpath
        do shell script command
        -- this won't be executed if the ditto command errors
        set command to "rm -r " & SaveLoc
        do shell script command
        return true
    on error
        return false
    end try
end trashfolder

(*
======================================
// GROWL SUBROUTINES
======================================
*)

on startGrowl()
    try
        tell application "System Events"
            set isGrlRunning to (count of (every process whose bundle identifier is "com.Growl.GrowlHelperApp")) > 0
        end tell
        ignoring application responses
            if isGrlRunning then
                set osaSc to "tell application \"Growl\"
set the allNotificationsList to {\"Import To OmniFocus\", \"Success Notification\", \"Failure Notification\"}
set the enabledNotificationsList to {\"Import To OmniFocus\", \"Success Notification\", \"Failure Notification\"}
register as application \"Outlook to OmniFocus\" all notifications allNotificationsList default notifications enabledNotificationsList icon of application \"OmniFocus\"
notify with name \"Import To OmniFocus\" title \"Import To OmniFocus Started\" description \"Processing Items from Outlook\" application name \"Outlook to OmniFocus\"
end tell"

                set shSc to "osascript -e " & quoted form of osaSc & "  &>  /dev/null &"
                ignoring application responses
                    do shell script shSc
                end ignoring
            end if
        end ignoring
    end try
end startGrowl


--ANNOUNCE THE COUNT OF TOTAL ITEMS TO EXPORT
on process_Items(itemNum, attNum, the_class)
    try
        tell application "System Events"
            set isGrlRunning to (count of (every process whose bundle identifier is "com.Growl.GrowlHelperApp")) > 0
        end tell
       
        set app_Path to (path to application "Microsoft Outlook")
       
        ignoring application responses
            if isGrlRunning then
                set attPlural to "s"
                set the_class to the_class as text
                if the_class is "List" then set the_class to "Outlook"
                if the_class is "Incoming Message" then
                    set growl_Icon to (path to resource "Mail.icns" in bundle app_Path)
                else if the_class is "Contact" then
                    set growl_Icon to (path to resource "vCrd.icns" in bundle app_Path)
                else
                    set growl_Icon to (path to resource "lcs.icns" in bundle app_Path)
                end if
                set growl_Icon to (POSIX path of growl_Icon) as text
               
                if attNum = 0 then
                    set attNum to "No"
                else if attNum is 1 then
                    set attPlural to ""
                end if
               
                tell application "Finder"
                    if the_class is not "Text" then
                        set Plural_Test to (itemNum) as number
                        if Plural_Test is greater than 1 then
                           
                            set osaSc to "tell application \"Growl\"
notify with name \"Import To OmniFocus\" title \"Import To OmniFocus Started\" description \"Now Importing "
& itemNum & " " & the_class & " Items with " & attNum & ¬
                                " Attachment" & attPlural & ".\" application name ¬
                            \"Outlook to OmniFocus\" identifier \"OmniFocus\" image from location \""
& growl_Icon & "\"
                            end tell"

                            set shSc to "osascript -e " & quoted form of osaSc & "  &>  /dev/null &"
                            my growlThis(shSc)
                        else
                            set osaSc to "tell application \"Growl\"
notify with name \"Import To OmniFocus\" title \"Import To OmniFocus Started\" description \"Now Importing "
& itemNum & " " & the_class & " Items with " & attNum & ¬
                                " Attachment" & attPlural & ".\" application name ¬
                            \"Outlook to OmniFocus\" identifier \"OmniFocus\" image from location \""
& growl_Icon & "\"
                            end tell"

                            set shSc to "osascript -e " & quoted form of osaSc & "  &>  /dev/null &"
                            my growlThis(shSc)
                        end if
                    end if
                end tell --FINDER
            end if
        end ignoring
    end try
end process_Items

on growlThis(shSc)
    ignoring application responses
        do shell script shSc
    end ignoring
end growlThis

--GROWL RESULTS
on growl_Growler(successCount, itemNum)
    try
        tell application "System Events"
            set isGrlRunning to (count of (every process whose bundle identifier is "com.Growl.GrowlHelperApp")) > 0
        end tell
       
        ignoring application responses
            if isGrlRunning then
                set part_1 to "tell application \"Growl\"
"

                set Plural_Test to (successCount) as number
                if Plural_Test is -1 then
                    set part_2 to "notify with name ¬
                    \"Failure Notification\" title ¬
                    \"Import Failure\" description \"No Items Selected In Outlook!\" application name ¬
                    \"Outlook to OmniFocus\"
                    end tell"

                else if Plural_Test is 0 then
                    set part_2 to "notify with name ¬
                    \"Failure Notification\" title ¬
                    \"Import Failure\" description \"No Items Exported From Outlook!\" application name ¬
                    \"Outlook to OmniFocus\"
                    end tell"

                else if Plural_Test is equal to 1 then
                    set part_2 to "notify with name ¬
                    \"Success Notification\" title ¬
                    \"Import Success\" description \"Successfully Exported "
& itemNum & ¬
                        " Item to OmniFocus\" application name ¬
                    \"Outlook to OmniFocus\"
                    end tell"

                else if Plural_Test is greater than 1 then
                    set part_2 to "notify with name ¬
                    \"Success Notification\" title ¬
                    \"Import Success\" description \"Successfully Exported "
& itemNum & ¬
                        " Items to OmniFocus\" application name ¬
                    \"Outlook to OmniFocus\"
                    end tell"

                end if
                set itemNum to "0"
                set combined_parts to part_1 & part_2
                set shSc to "osascript -e " & quoted form of combined_parts & "  &>  /dev/null &"
                my growlThis(shSc)
            end if
           
        end ignoring
    end try
end growl_Growler

72 Responses to “Outlook 2011 to OmniFocus”

  1. Mac says:

    Just trying your script but I don’t have Growl installed. So it get stuck as it searches for GrowlHelper. Can it be deleted?

    • Justin says:

      Just made a small update to the code… is it working now?

      • Mac says:

        Unfortunately not. When I tried to compile the script, it still asked for GrowlHelperApp in a pop up window.

        And then there was syntax error.
        Quote—
        Expected “given”, “into”, “with”, “without”, other parameter name, etc. but found “”".
        End Quote—
        This referenced the line: “Failure Notification” title ¬

  2. Shaun says:

    Hi Justin,

    I am trying to install your script but when I open it with my script editor and then try and save it I keep getting the following errors about 7 – 8 times;

    Expected “,” but found property
    Expected expression but found “of”

    They both appear about 4 times each. When i go through and remove what i think are the culprits and then run the script again I get the Omnifocus notification that it has started trying to import something but then I get another error that says;

    Import failure
    Failed to export item due to the following error
    “The variable selecteditems is not defined”

    Can you help with this? Your script seems to be the best one in terms of what it offers as all the other ones I have found only send emails form Outlook and not Calendar items. I need the calendar items more than the emails to be honest.

    Cheers

    Shaun

    • Justin says:

      Hi Shaun,

      That’s really odd! Haven’t seen/heard of that happening before…

      Let’s try to sort out what’s causing the issue:
      To me, it sounds like the script isn’t compiling correctly on your end. Instead of using the ‘Open in Script Editor” button, try cutting-and-pasting the code into your Script Editor and then compiling. Does that work?

      • Shaun says:

        Wow that’s a quick reply. Thanks a lot.
        OK I tried copying and pasting directly into a new page in the script editor and then ran it and I get the same error. Exactly the same errors.

        • Justin says:

          I do what I can… ;)

          Seriously, though — It’s really important to me to make sure that people can get these scripts up and running (especially in the early days of putting a beta out into the world).

          Probably better if we try to diagnose things one-on-one via email. I’ll send you a copy of the script (one that is compiling fine on my system) as an attachment. If it still isn’t working, we can drill down deeper to see what’s going on!

          Let me know via the Contact Form if you don’t receive it!

  3. Justin says:

    FYI — Shaun’s issue was caused by running an older version of Outlook 2011. This AppleScript requires SP1 (Version 14.1.0) or greater.

    I’ll update the script’s notes to reflect that in case this crops up again!

  4. Mark Duffield says:

    Working great for me with Outlook and OmniFocus. Thank you! This is the missing link for me.

    • Justin says:

      Mark,

      I really appreciate you taking time to let me know that it’s working well — hope you enjoy it!

  5. Jan says:

    Justin,

    still a newbie in Applescript, so I am not able to say where the error is…

    if trying to save/compile the code, I receive multiple syntax errors:
    if raw_Class is calendar event then set the_class to “Calendar”

    if raw_Class is incoming message then set the_class to “Message”

    the two words seems to be problem, expecting Then

    and the second part:
    set r_2 to (start time of theProps) expected “,” but found property, same with end time, one line below…

    Please help, Jan

    • Justin says:

      Hi Jan!

      That’s odd. Let’s get a little more detail — Are you cutting-and-pasting the code into the AppleScript Editor or did you use the “Quick Link” button that I have underneath the code? What version of OS X, Outlook, and Evernote do you have?

      • Jan says:

        I tried both ways: cut & paste and opening in AppleScript Editor…

        all the latest versions:
        Evernote: 2.1.0
        Omnifocus: 1.9
        Outlook: 14.1.0 (110310)
        Mac OS X 10.6.7

  6. Justin,

    Thanks so much for this wonderful and promising script. It truly is the missing link for me! Now I can delete that Entourage-based script I was using for a while, which always worked but ended with some sort of error-message. What you have here is remarkably elegant.

  7. Paul Bain says:

    You may want to check out the coding that is being used in the AppleScript at http://rainer.4950.net/wordpress/blog/2011/02/15/outlook-to-omnifocus-take-4/

    What’s nice about this script is that it includes the message as an attachment which can be opened.

    • Justin says:

      Hi Paul,

      I saw Rainer’s script and agree that, if you’re looking for the message as an attachment, it’s a pretty nice solution!
      (And also a good one if you prefer to use the Quick Entry Dialog)

      For my script, I decided to take a different approach: I wanted something that could transfer all Outlook items — not just the messages. Since I also present the scripts here as a way to help people learn AppleScript, I also wanted something that was self-contained and written in pure AppleScript (Rainer’s depends on an external Java file called “MailDecoder.jar” to get the job done).

      There are usually multiple ways to get to the same end result and I almost always learn from seeing how other people approach their own scripting projects. This is one of my favorite parts of AppleScript and why I wanted to have a code library… People should check out Rainer’s script at the link above and I’ll be sure to leave a link on Rainer’s site so that people know about this version as well!

  8. Nitin says:

    Is there a similar way to pass an outlook object over to Omni Outliner?

    Great script for OF, by the way.

    • Justin says:

      I can’t say for certain because I haven’t written anything for OmniOutliner yet (though that may change now that I’m using the hell out of the iPad version of OmniOutliner. However given Omni’s generally deep support of AppleScript in their products, I think it would probably be achievable!

      Tell me — how would you imagine it working?

  9. Doug says:

    Terrific script – thank you!

    I was wondering if there was a way to do:

    1. Define a rule that runs your script for autoprocessing of selected incoming emails? I’d like to automatically send selected emails to OF.

    2. Allow me to auto-set OF’s Context and Project fields. I have some of my Contexts set to the name of key people. When I receive an email, I’d like the Context to be auto-determined. My thought is that there would be a set of “If..then..else” statements in the script that would say, if the email from name contains “Bob.Smith”, then set the OF Context to “BSmith”. Same kinda idea with Projects.

    BTW – Tried to use your script for auto-processing and all I get in OF is a task with “Text Clipping from Outlook” as the note.

    Thanks again for putting this together – I really appreciate it!

    Doug

    • Justin says:

      Hi Doug,

      I haven’t done this yet, but I think it’s possible!

      I’m guessing you’d need to modify the script in the following ways:

      1. Place the whole script inside an “on run” block (Here’s an example of that using Outlook’s predecessor, Entourage.)
      2. As you were thinking, some If/Then statements which set the Projects/Contexts. Here is some sample code that shows how to work with contexts and projects.

      If you successfully put together a “Rule Ready Version”, be sure to let us all know how it worked out for you… Good Luck!

      • Doug says:

        Thanks, Justin! I appreciate the feedback, examples and encouragement. I’ll let you know how it turns out. Apple scripting is way outside my comfort zone, so no promises! Thanks again!

  10. Doug says:

    Hey Justin – I’ve made the changes that support automatically determining start and due dates, contexts, and projects. I also added the ability to optionally load OF in the background or in the foreground (via quick entry). If you send me your email, I’ll send it to you.

    A few challenges I’d like to overcome:

    1. Is there a way for the script to know what the key commands were that initiated it? I’d like to be able to use the same script to optionally load the OF task in the background and foreground. At the moment, I have a switch at the top of the script and I create two scripts to do one or the other.

    2. I’d like to be able to use this script to run based on a rule on incoming emails. OF has one that they use for Mail, but I can’t get this process to work using this script. It basically uses the highlighted inbox message and not the email that initiated the rule.

    3. I tried to use sub routines, but I was not successful. So, the block of script that determines dates, contexts, projects, etc, is in two places to support background and then foreground processing.

    4. Lastly, your script does not attach attachments to the OF task. Growl says that it is doing it, but it does not. Is there a later version of the script?

    Thanks again for the coaching!

  11. Jay says:

    Great script! I have been using another one I found on the internet, but this one is much faster and I love the growl notification. I have a request – can you have a link to the original email message posted into the notes section along with the text of the outlook message?

    This would be much appreciated!

    • Justin says:

      I would love to do this but, as far as I know, Outlook currently lacks the ability to create Direct Links to its messages… but I’ll keep my eyes open and add it should that ever be enabled!

  12. Glenn says:

    Hi – would love to get this working – having the GrowlHelperApp window popping up. What should I do next? Use a modified script? Thx

  13. Doug says:

    Justin – do you want me to send you the script I updated? As I mentioned, I’ve made a number of changes that may be generally helpful. Please send me your email if you’d like for me to send it to you.

    Doug

    • Justin says:

      Hi Doug — Apologies! I must have missed your original comment somehow. :(

      Would love to see your mods! FYI — the best way to send compiled AppleScripts to me is via the AppleScript Submission Form. By doing so, it makes it easy for me to share it with everyone in the Code Library and give you proper attribution for your contributions.

      Looking forward to checking it out!

  14. Eric says:

    Hi Justin,

    Does this require the latest version of OmniFocus? I am still using 1.7.5 and have not upgraded–it looks like I can export highlighted text but am unable to directly copy messages, etc.

    • Justin says:

      That’s a good question, Eric!

      I built this script on OmniFocus 1.9 and I don’t have any other versions installed to test for compatibility. Anyone out there running this on an earlier revision?

  15. Adam says:

    Justin,
    This is a great tool. Much appreciated. I know nothing of writing code / managing scripts… I’m an executive who loves mac and omnifocus… I almost didn’t try this because it was way over my head… the perceived benefit was greater than the risks so I dove in… Being completely lost, I clicked on the quick link you provided to script editor, saved it to the location you specified, copied your file name and pasted it in… Works like a charm. Could be the best couple of minutes I invest all week! Thank you for making it easy!
    Adam

    • Justin says:

      Adam,

      Thanks so much for your kind note!

      You put your finger on something that I’ve been wondering about: Whether people come here, see the code, and feel intimidated or like it’s “over their head”.

      I’ve been working behind the scenes on the next version of Veritrope.com, trying to come up with a way to present things that is useful to new and experienced users alike. (Suggestions, as always, are welcomed by using the Contact Form or with a note to the Veritrope.com Twitter account)

      Anyhow, I’m certainly glad you decided to “take the plunge” and am very happy to read how well things are working out for you!

      • Adam says:

        Justin,
        Thanks for the kind reply last month. Wanted to let you know that I recently had a microsoft update come through that wiped out the script (at least I think that is what did it). I went through the process of reinstalling it and it works well again… thank goodness… but just in case you get a flurry of these issues it was completely wiped from my script folder… I look forward to venturing out further into Veritrope to see what else I can learn/use.
        Thanks again for making it easy!

        Adam

  16. Doug says:

    Justin,

    This is an outstanding tool. I like Adam am also an executive who knows nothing about code. I was able to get this up and running in five minutes. Being able to integrate my emails to Omni was the biggest reason I put off buying it for so long – as most folks – I live out of my inbox and nothing has the power of OF. Thank you again – very nice job!

    • Justin says:

      Doug,

      I’m so glad to read that this script helped you as well!

      As I mentioned to Adam above, I’m working on ways to demystify tools like these to newer users and comments like yours reinforce the value of this.

      Thank you so much for taking time to share your experience!

  17. bob says:

    great script (for me new to Mac and OF).
    i installed and it worked perfectly, then i changed default programs to Mac mail to test something else out, then when i changed back to Outlook 2011, the script no longer works… i tried removing and then reinstalling, still no luck… any ideas?

    • Justin says:

      Hi Bob — Glad that you like the script!

      Your issue is a bit of a head-scratcher… but let me send you an email to outline some basic troubleshooting steps to see if we can figure it out.

  18. Steven Perich says:

    Hi there,

    LOVE the script. Thank you for writing it. I really like how it can be used for other things apart from emails!

    I am running Outlook 2011 14.1.3 at present and I noticed that when I try to import a contact (by clicking it and invoking the script) I get an error:

    Item Failed to Import: -1278
    Microsoft Outlook got an error: Can’t get every attachment of item 1 of contact id 2.

    Any ideas?

    • Justin says:

      Thanks for your kind comment, Steven!

      I made a slight tweak to the code to see if it would avoid this error. Download the new version (I’m calling this 1.00 Beta 1) when you get a chance and let me know if it does the trick.

  19. Steve Nunez says:

    Thanks for the script. Just what was looking for. One suggestion: a pop up entry windows, similar to how the Omnifocus (clip-o-tron) mail clipping services works would be great. This would let you clean up the task before saving it.

    Is this possible?

    • Justin says:

      @Steve –I think it would be possible to integrate this into the script for single items. My original concept avoids the quick entry tree because I felt that, for multiple items, it would be faster to just get everything into the inbox.

      Veritrope readers — Would this be helpful to you? Any other thoughts or suggestions?

  20. Eldar says:

    Working great for me with Outlook2011 and OmniFocus. Thank you!

  21. DanitaZ says:

    This is working well for me, except that the growl notification is not popping up. I just have to learn to “trust” that the items are getting to OmniFocus. But otherwise it’s a gem!

    • Justin says:

      Thanks for the donation, Danita! :-D

      Question about your GROWL issue: Do you have the newer, “app store” version installed or the older version?

      • DanitaZ says:

        Oh good point! I’m pretty sure it’s the older version. I keep getting “nagged” to upgrade, but it was “working” for everything else, and I’m an “it’s not broke, don’t fix it” type generally. I can go put the newer version on and see if that helps!

  22. John says:

    Many many thanks for this, works very well (once I had selected the right bits), really appreciate your hard work in writing and sharing this.

  23. Dennis says:

    Thanks SO much for this great script, Justin. It’s the missing link that has allowed me to transition my workflow from Outlook tasks with attachments on Windows to Outlook on the Mac (required for work) with OF as my task manager. I can’t thank you enough!

    Would it be possible to create a modified version of the script so that the experience is slightly different? Specifically, so that when you run it you get the OF new action window opened up with just the Outlook item as an attachment (without the full text of the outlook item in notes), and the cursor ready to type the name of the new action? This would be good because the name of the action is usually not the same as the subject line of the e-mail. It would also align the experience with the standard OF new action window, and allow the user to assign project/context/start, etc., which has been requested by others on this forum.

    My AppleScript skills are non-existent so I’m putting the request out to you. Again, thanks for the script. I’d been searching high and low for something like this.

    - Dennis

  24. Ross Williamson says:

    Great script use it all the time. There is one feature request – can the created OF item contain a link to the original email. Most often I am creating tasks to emails that I need to provide responses to, and it would be good to be able to click on a link in the email to get back to outlook (like the script you have for Apple Mail to OF)

    Cheers

    Ross

    • Justin says:

      Hi Ross — Thanks!

      Outlook doesn’t currently allow for “URI Links” to its messages the way Mail does.

      If they add it, so will I! :-D

      • Ross Williamson says:

        Justin,
        Could we then attach a file version of the email to the OF item? Basically so i can then open the attachment and then just reply to the email? Otherwise you have to start a new email to respond to the OF item. Did that make sense?

        Ross

  25. Russell says:

    Hi this script is fantastic and just what I was looking for however I am new to applescripts and wondered how easy it would be to amend the script so that processed emails were automatically saved in a new folder.

    Thanks
    Russell

  26. Atholl says:

    Thanks it worked like a charm

  27. Brad says:

    A really nice feature of the Mac Mail to Evernote script was a custom link back to the original email. Is there a way to enable this functionality in the Outlook 2011 to Evernote script? Great script by the way, saves me a bunch of time!

    • Justin says:

      Hi Brad,

      Sadly, I believe Outlook doesn’t (currently) have the capability to do this.

      As soon as Microsoft adds it, I will too!

      • Rick says:

        Created the script (with scpt AND scptd file extension), putted it in the right folder (made sure by doing it via Outlook>script icon>About>show in finder>.
        After that, restarted outlook. its not showing up in the list with the rest of the scripts ?

        I have the right version of outlook (2011 SP2).
        Why doesnt it show up with the rest of the scripts ?

        • Justin says:

          Hi Rick,

          In rare cases, another script in that folder will have an issue which prevents any new scripts from appearing in the list.

          Other people have told me that moving all of your scripts out of that folder and adding them back in one at a time is a good way to identify the problem AppleScript. Give it a try and let me know how it works out for you!

          • Rick says:

            Hi Justin,
            Thanks for replying so quickly.
            I just kicked out all scripts except the omnifocus script.
            restarted outlook, nothing showing in the Script menu. Got any idea ?
            Rick.

            • Justin says:

              The only other thought that occurs to me right now is to:

              1. Open up a new, blank document in AppleScript Editor;
              2. Paste the code from the OmniFocus script into the blank document
              3. Save this “new” AppleScript to the Outlook script folder with a different name.

              … and, of course, all of the usual stuff – Outlook restart, System restart, etc. if it still isn’t showing up!

              • Rick says:

                Justin, this is completely weird, but i followed up on your tip. It worked :|
                i think it would save a lot of people time, if you could just post the script online instead of copy’n'pastin it ;-)

                Thanks for helping out !

  28. Andrée says:

    Hi Justin.

    I just started to use Omnifocus and i have all my hundreds of todos in an Exchange enviroment. I tried to find a solution like yours but with no luck until now and it works like a charm. Thanks a million! I will surely check out your other posts and se what i can use.

    Thanks again!

    I wish you a very Happy New Year!

    Best regards

    Andrée

  29. Pablo says:

    Justin, I absolutely love this script!

    Is there a way to stop sending email attachments to OF? I’m using a different system where I store the attachments separately…

    Thanks again for a great thing

    • Justin says:

      If you want to skip the attachments, I think you can edit out this line with no ill effect:

      if theAttachments is not {} then my message_Attach(theAttachments, theProps, NewTask)

      In future versions, I’ll look at adding a switch to do this.

      • Pablo says:

        I commented it out and it worked – a true/false switch would be nice, but the real kicker would be to have it send to OF the file names that are not included within the body of the text (i.e. as when you reply to someone’s email w/o reattaching the files, but including the names). This would help people to remember which files to look at when they open the todo. Makes sense?

        Cheers and hope Laos is proving fun for you this w/e!

rss Subscribe to Comments RSS Feed


You can use these tags in your comment: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>