Migrating emails from Notes to Outlook (or, programming for failure)

My huge archive of Lotus Notes emails started almost ten years back, and I stubbornly kept most of it around because of why not. Now that I use Outlook 2013 you can imagine I would have liked to have all of them also in my brand new email client. One sure could get some commercial software to do it, but why shouldn’t I try converting them myself? I mean, look, a simple drag and drop from Notes creates in Windows Explorer EML files and we all know EML is a very much standard format (RFC822 or so). Or at least that’s what I thought – Outlook 2013 thinks differently and will not import EML files. Only Outlook Express or Microsoft Live Mail can do that, but who cares about these anyway?? So what are my options?

First I noticed that if you open your EML file with Outlook it will create a dumb unusable entry. Buuuttt, if you keep that entry open then click the “save” button, it will create ALSO a proper message – right there in my Inbox! Proper means it will have the right subject and sender, will include all attachments, and will have even the right timestamp! I can delete then the dumb entry and move the fresh message from inbox to the proper folder, nice. All I ever dreamed of, too bad this method doesn’t scale at all – did I mention I have tens of thousands of emails?

If Outlook can still achieve that, it means not all hope’s lost as functionality must be there somewhere under the hood… VBA scripting time! Google is my friend, and after fiddling around with the clumsy objects Outlook puts at your disposal, I realized I should rather seek help from the professionals. There’s this Redemption library, free for developers but only 250$ for your company (yeah, nothing), which you can download, install, and you’ll have a suite of very handy COM objects to play with your Outlook interfaces. I’m aware this way is more geared towards the developers, after all who knows what’s a COM and how to enable them? (hint: in Outlook’s VBA editor open Tools/References and check the Redemption entry way down the list). Anyway, I wrote a nice small script which was taking all the EML files from a directory then importing them in an Outlook folder of my choice. I thought I’d move then the fresh emails into the correct folders by hand after that, so what. I said already it will be a developer-oriented method…

batmannotquite

Unfortunately, soon it turned out I was perfecting the wrong end of the problem. Lotus Notes 8.5.2 has a bug which lets it drag&drop only 100 emails at a time, regardless how many you might have selected. The bug was recognized long time ago by IBM/Lotus and the official statement at the time was “A programming error was found but will not be corrected. It will be a permanent restriction.”. Don’t you love them, big programming houses, all claiming innovation and big talent and whatnot? Meh. As I’m certainly not planning to drag and drop my tens of thousands of emails one hundred at a time, the road forward is blocked regardless of the brilliant simplicity of my script.

So, what did I learn out of this? One reason more to despise Lotus Notes? That not every effort will pay off and the world isn’t fair? That buying software can many times be the best way forward? Nothing new, actually… Anyway: below you’ll the VBA code doing the EML-to-Outlook import, maybe somebody can use it for a teaching example or whatever else. Enjoy.

Set objNamespace = Application.GetNamespace("MAPI")
Set objInbox = objNamespace.GetDefaultFolder(olFolderInbox)
objParent = objInbox.Parent
Set objImport = objNamespace.Folders(objParent).Folders("temp").Folders("imported")
mailsPath = "C:\temp\export\"
fileName = Dir(mailsPath & "*.eml")
While (fileName <> "")
    Debug.Print fileName
    Set objPost = objImport.Items.Add(olPostItem)
    Set objSafePost = CreateObject("Redemption.SafePostItem")
    objPost.Save
    Set objSafePost.Item = objPost
    objSafePost.import mailsPath & fileName, RedemptionSaveAsType.olRFC822
    objSafePost.MessageClass = "IPM.Note"
    objSafePost.Save
    fileName = Dir
Wend
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s