Wednesday, July 2, 2014

Exporting emails from Entourage to Outlook

I’ve recently had to export a bunch of emails from Entourage and into Outlook, in order to send them to someone in a format they can browse and read on a PC.  You’d think that exporting a selection of emails from one Microsoft email management tool to another would be easy, right?  Sadly not.  Thankfully, a bit of Apple script got things working for me.  This post describes how.
The main problem is the lack of a common format between Entourage (.mbox for folders, .eml for individual emails) and Outlook (.pst for everything).  There used to be a really good Applescript export tool for exporting from Entourage, but sadly it’s never been updated to work on Leopard.  You can export a whole folder as an MBOX file from Entourage, but these can’t be opened by Outlook and so aren’t much use either.
My eventual solution has two parts – getting mail out of Entourage, and then getting it in to Outlook.

Getting mail out of Entourage

For this part, I find an Apple script (based heavily on some code from macosxhints.com) to export all currently-selected emails in Entourage to a folder on my Mac.  Many thanks to macosx hints user Golgi body for posting the original code.

You just have to select emails from Microsoft Entourage, inbox ( or whichever folder you want to) and run the script so it will save individual mail in .eml format sorted by date wise to the desired folder (location where fpath is specified in script)

Here’s the script I’m using (copy this into Script Editor to use it):
Apple Script Editor app

----------------------------------------------------------------------------------------------------------------
tell application "Microsoft Entourage"
 
    -- get a reference to all selected messages from entourage
    set selectedMessages to the current messages
    if selectedMessages is {} then
        return
    end if
 
    -- absolute reference to our export folder
    set fpath to "DiskName:Users:myusername:Documents:existingfolder:"
    --set fpath to "Macintosh HD:Users:Sanjay:Documents:export:"
 
    repeat with i in selectedMessages
 
        set sentDate to time sent of i
        set fname to fpath ¬
            & my padNumber(year of sentDate as integer) ¬
            & "-" & my padNumber(month of sentDate as integer) ¬
            & "-" & my padNumber(day of sentDate as integer) ¬
            & "-" & my padNumber(hours of sentDate as integer) ¬
            & "-" & my padNumber(minutes of sentDate as integer) ¬
            & "-" & my padNumber(seconds of sentDate as integer) ¬
 
        tell application "Finder"
            if (exists file (fname & ".eml")) then
                set k to 1
                repeat while (exists file (fname & "-" & (k as string) & ".eml"))
                    set k to k + 1
                end repeat
                set fname to (fname & "-" & (k as string))
            end if
        end tell
 
        set fname to fname & ".eml"
        save i in fname
        tell application "Finder" to update file fname
 
    end repeat
 
end tell
 
to padNumber(theNumber)
    if theNumber is less than 10 then
        return "0" & theNumber
    else
        return theNumber
    end if
end padNumber
----------------------------------------------------------------------------------------------------------------
You’ll need to set fpath to be the path to an existing folder on your Mac. When you run this script in Script Editor, all of the selected files in Entourage will be exported to your export folder as .eml files.
Why use Applescript at all?  Why not just drag the selected emails onto a folder?  After all, this prompts Entourage to export them itself in .eml format.  The problem is, when you do so, Entourage exports the emails using the email subject as the file name.  This can contain all sorts of weird and wonderful characters, and Windows doesn’t like that at all.  This script avoids the problem altogether by using the date and time the email was sent as the filename.  (It also makes it easier to order your .eml files by date and time in the Finder if you need to.)

Getting mail in to Outlook

For this part, I used a Drag Drop method to get .eml files into inbox which works pretty well for free of cost. You can get bunch of paid apps to do this work for you.
I’ve only tried this process myself with Entourage 2008 (on Leopard) and Outlook 2003 (on XP), but I would expect it to work with earlier versions of Entourage too.  The Outlook Import Wizard should be good to go no matter what your setup.

No comments:

Post a Comment