Auto-filing from Outlook for Mac

Why would I go back to Outlook?

For number of reasons, I am unfortunately going back to using Outlook on my work machine. I was able to go with Mail and, for the past year, BusyCal. It was great except for Exchange. Turns out that Exchange is pretty vital to the whole experience of Email and Calendar in my work-life. Exchange has problems all on its own. There are issues at work between even the different versions of office on PC's. Macs bring more issues. BusyCal isn't the issue. If I could still use BusyCal, I'd probably not make the switch. I lost access to BusyCal as it seems to have fallen off the corproate whitelist for access to Exchange. So much of my issue is with Calendar. I've had multiple issues with calendar items simply not syncing with Exchange. The final straw was moving a meeting on Calendar and having the series disappear! With any of my more important meetings and meetings with large distribution lists, I had been opening Outlook to manage these. So to answer my own questions, I have a lack of confidence in Calendar syncing properly and to manage an Exchange based connection.

Switching Back

I've been keeping the Outlook option open all along so it was simple to switch over except with 2 issues. First, I didn't have my auto-filing scripts set up for Outlook. Second, my archives from Mail won't import into outlook (after exporting in .mbox format). I won't deal with this at the moment.

I missed my auto filing scripts immediately and have adapted the script. I miss BusyCal daily and am reduced to hoping the next Office for Mac improves.

Script Update

Applescript support for Office for Mac is very good so this wasn't a problem beyond my lack of experience at scripting Outlook. Ultimately, this was solvable and the results are below. The script replaces my Mail script and does what I've described previously.

Dual Stream Filing Approach

I took the opportunity to set up a second script that auto tags and puts the document on the desktop (with Hazel). The reason for this is that I save too many files which does often complicate the process of me finding files quickly. So my approach is to have a "curated" pile of files that go through the desktop and then the balance of files in a separate pile that go through the inbox. I'm much more likely to be looking for the files that I've been working with on the desktop. With Tembo, I can target a search easily for either set of files.

The key to this is Hazel. The scripts simply save the files to two different nested folders based on the senders name. From here, Hazel tags them using dynamic tags and either puts them on the desktop if they are from one set of nested folders or my inbox for the others. Not the most elegant solution but since its really just a bunch of empty folders most of the time, its not an issue.

The Script

also can be found my github repository.

– set up the attachment folder path
tell application “Finder”
    set folderName to “Attachments”
    set homePath to (path to home folder as text) as text
    set attachmentsFolder to (homePath & folderName) as text
    – display dialog attachmentsFolder
end tell

tell application “Microsoft Outlook”

set theMessages to selection
repeat with eachMessage in theMessages

    -- set the sub folder for the attachments to the first part of senders email before a period
    -- All future attachments from this sender will the be put here.

    set theSender to sender of eachMessage
    set theAddress to address of theSender
    -- display dialog theAddress

    set AppleScript's text item delimiters to "."
    set senderName to text item 1 in theAddress
    set subFolder to senderName
    -- display dialog senderName

    -- use the unix /bin/test command to test if the timeStamp folder  exists. if not then create it and any intermediate directories as required
    if (do shell script "/bin/test -e " & quoted form of ((POSIX path of attachmentsFolder) & "/" & subFolder) & " ; echo $?") is "1" then
        -- 1 is false
        -- display dialog attachmentsFolder & "/" & subFolder
        do shell script "/bin/mkdir -p " & quoted form of ((POSIX path of attachmentsFolder) & "/" & subFolder)

    end if

        -- Save the attachment
        repeat with theAttachment in eachMessage's attachment

            set originalName to name of theAttachment
            set savePath to attachmentsFolder & ":" & subFolder & ":" & originalName
                save theAttachment in file (savePath)
            end try
        end repeat
        --on error msg
        --display dialog msg
    end try

    -- set theArchiveMailboxName to "Processed"
    -- if (mail folder theArchiveMailboxName exists) = false then
    -- make new mail folder with properties {name:theArchiveMailboxName}
    --   end if
    -- repeat with aMessage in theMessages
    --  move aMessage to mail folder theArchiveMailboxName
    -- end repeat

end repeat

end tell