September 23, 2005

My Lotus Notes Adventure

A task at work required us to convert Lotus Notes .nsf files containing contacts and email messages, such that we could import them into the clients' brand new Exchange Server. We were in an environment where connecting to both servers was not going to be possible, and we received the Notes Files on a DVD from the customer. At first, I thought that this was going to be a simple task, and that imports would be a matter of just telling Outlook to import the file. Since I'm writing this entry, you can be assured that it was not so simple.

There are a good many products out there that will convert Notes data for you. Unfortunately, most of them cost a good deal of money. I found one that was very inexpensive, and served half of our needs. The tool is Notes2Outlook. While the tool is still very immature (it terminates without warning when it hits an error, and is very sensitive about how you start it up, it doesn't clean up its own temp files, but can crash if you don't clean them up manually...that kind of thing), it did work for us in migrating email messages to PST files from NSF files. It was also cheap - $160 for a 3-month subscription, more than long enough to do a one-time import.

To do the import, you need to make sure you get a Lotus Notes client. If you're doing this process, you're probably an Outlook/Exchange Administrator, and don't know much about Notes. This is where I was a week ago. Make sure you get a copy of the client from the people who give you the .nsf backups. It's the only way you'll ever be able to read the .nsf files. There is no open source solution to accessing the emails, even if you spend $1000 or more for an import tool. The Exchange Migration Wizard and Lotus Notes Connector even requires installation of the Lotus Notes Client on the Migration machine.

Once you have the client, make SURE you can open the .nsf databases you were given. One of the .nsf files we received had 'local access protection' on it, and could not be opened by the Notes client. This causes all kinds of consternation when we tried to import it, and we had no idea that the problem was linked to the Notes client being unable to read the file. To do this, open the Notes Client, choose File, Database, Open and select the .nsf file. Make sure this brings up the messages you wish to import, or the contacts you wish to import. You'll be using the Notes client to do the import of contacts, anyway.

Install both MS Outlook and the Notes client on a fast machine. Install Notes2Outlook on the same machine. Begin your imports. A few tips:
  • Open Outlook before starting Notes2Outlook. The programmer tries to instantiate it when it runs, but Outlook can be touchy when starting up, and the instantiation is best done while Outlook is already open and in memory.
  • Make sure you specify a Working Directory that is EMPTY. Choose a different working directory for each import as you go along.
  • Don't close Notes2Outlook in between conversions. We had a hard time with it opening back up cleanly. Just do all your imports with the one session.
  • Don't choose the All option. It makes for a very big PST file.
  • Notes2Outlook has a counter that appears on the screen down in the left bottom - but it's NOT in the Notes2Outlook window. When you start the application, move the Notes2Outlook window so that the counter can easily be seen on the backdrop of the application. There should be a status message when you start the application.


Now for the names.nsf file - the contacts. The Notes Client is good here, because it will export a VCARD file. Just choose Export, and you can Export an address book to a VCARD 3.0 file containing all of the contact information. There is one small problem, however. Microsoft Outlook does not understand multiple-entry VCARD files. That's just STUPID, but that's how it was when we tried to import the entries in Outlook 2003.

To solve this problem, I wrote a .VBS script that opens up the VCARD file and separates the VCARDS into their own files. Here it is:

Dim ifs, ofs
Dim infile,outfile

PATH = "C:\Notes Contacts\UserName\"
INFILE = "names.vcf"
OUTFILE = ""
i = 0

Set ifs = CreateObject("Scripting.FileSystemObject")
Set infile = ifs.OpenTextFile(PATH&INFILE,1,0)

intext = infile.ReadLine

Do Until infile.AtEndOfStream

'Check to make sure we're at the beginning of a VCARD.
If Left(intext,11) = "BEGIN:VCARD" then
i = i +1
OUTFILE = CStr(i)&".vcf"
Set ofs = CreateObject("Scripting.FileSystemObject")
Set outfile = ofs.CreateTextFile(PATH&OUTFILE,True)
'Begin building game buffer
outfile.WriteLine intext
intext = infile.ReadLine
Do Until left(intext,9) = "END:VCARD"
outfile.WriteLine intext
intext = infile.ReadLine
Loop
outfile.WriteLine intext
outfile.Close

Else
intext = infile.ReadLine
End If
Loop

infile.Close

Set ifs = Nothing
Set ofs = Nothing

To use it, just change the pathname of where you put the .vcf file that Notes creates, and this will make a series of files in that directory: 1.vcf, 2.vcf, etc.
I would recommend creating a directory for each user and running this split.vbs program on each directory.

Finally, you can drag and drop the .vcf files directly into the Outlook Contacts folder. When you do, you'll have to Save and Close each one (by default Outlook opens up the vcard, rather than saving it). You can likely hold down Alt-S on the keyboard to quickly do that.

I hope this blog entry helps some other poor sucker with their Lotus Notes to Exchange Migration or NSF to PST conversion. I know I was looking for a free solution on the Internet, and didn't find one. If the Notes client has an open API, perhaps some nice Open Source programmer will write a free converter. Until then, however, this is an inexpensive solution.

2 comments:

Anonymous said...

Thank you very much for the VBS script - it worked!

thomasmappbe said...

thanks