Data export, delivered

From time to time I get recruited to help someone export mail and contacts from one e-mail program and import the data into another. The fact that a civilian must recruit a geek to accomplish this seemingly mundane task speaks volumes about our industry's sad history of data lock-in.

Even for a geek, the solution can easily become a slide down a slippery slope. There's no shortage of converters floating around on the Net, but it's surprisingly hard to find one that will reliably and completely transform, say, WAB (Windows Address Book) to LDIF (LDAP Data Interchange Format) or CSV (comma-separated values).

Back in 2002, I discovered that Mozilla's mail program, now known as Thunderbird, could import mail and contacts from an Outlook PST file and then export the data as Mbox for mail and LDIF or CSV for contacts. My referral log tells me that, to this day, people continue to seek out and use that technique.

It came in handy again this week when a friend wanted to switch from Outlook Express to Gmail. Exporting her contacts to a CSV file, and then importing them into Gmail, turned out to be a snap. But when I declared victory, she sent me scrambling down the slippery slope with this innocent-sounding question: "What about my distribution lists?"

Uh-oh. It turns out that she uses 15 lists, some with just a few individual addresses and some with more than 100. Those lists didn't appear in the CSV file, or in the output of any other WAB converter I could find. Even my trusty Thunderbird trick only partly worked. Although Thunderbird can export lists to LDIF, it does only one at a time, so I had to create a file for each separate list. Grumble.

With half the battle won, how to inject those LDIF files into Gmail? There's no official Google-supported API, but I've gotten lots of mileage out of an unofficial one called libgmail. Good news: libgmail has added support for Gmail contacts since I last used it. Bad news: It only supports individual contacts, not lists.

The solution I cobbled together speaks volumes about the fundamental openness of Web applications. To find out how Gmail creates a distribution list, I logged in, created a list interactively using Gmail's form, and captured the resulting HTTP transaction using one of the handiest tools in my Web developer's kit, Firefox's LiveHTTPHeaders extension.

The next step was to replay that transaction outside of the browser. I rearranged its elements -- a URL, a chunk of HTTP POST data, and a set of HTTP headers including a cookie packed with crucial name/value pairs -- as a command-line invocation of another of the handiest tools in my kit: curl.

As proof of concept, I used Gmail's interface to delete the list I'd just made, then invoked the curl command to recreate it. When that worked, I wrote a simple script to interpolate names and addresses from the exported LDIF files into a series of curl commands, and invoke them one at a time. And that was that.

It was only a partial solution, of course. A fully automated version would tie into libgmail's authentication scheme, obviating the need to capture and replay an HTTP header. But the fact that it's possible to discover and exploit implicit APIs in this way is a testament to the power and flexibility of the Web's architectural style.

Join the newsletter!


Sign up to gain exclusive access to email subscriptions, event invitations, competitions, giveaways, and much more.

Membership is free, and your security and privacy remain protected. View our privacy policy before signing up.

Error: Please check your email address.
Keep up with the latest tech news, reviews and previews by subscribing to the Good Gear Guide newsletter.

Jon Udell

Show Comments

Cool Tech

Toys for Boys

Family Friendly

Stocking Stuffer

SmartLens - Clip on Phone Camera Lens Set of 3

Learn more >

Christmas Gift Guide

Click for more ›

Brand Post

Most Popular Reviews

Latest Articles


PCW Evaluation Team

Aysha Strobbe

Microsoft Office 365/HP Spectre x360

Microsoft Office continues to make a student’s life that little bit easier by offering reliable, easy to use, time-saving functionality, while continuing to develop new features that further enhance what is already a formidable collection of applications

Michael Hargreaves

Microsoft Office 365/Dell XPS 15 2-in-1

I’d recommend a Dell XPS 15 2-in-1 and the new Windows 10 to anyone who needs to get serious work done (before you kick back on your couch with your favourite Netflix show.)

Maryellen Rose George

Brother PT-P750W

It’s useful for office tasks as well as pragmatic labelling of equipment and storage – just don’t get too excited and label everything in sight!

Cathy Giles

Brother MFC-L8900CDW

The Brother MFC-L8900CDW is an absolute stand out. I struggle to fault it.

Luke Hill


I need power and lots of it. As a Front End Web developer anything less just won’t cut it which is why the MSI GT75 is an outstanding laptop for me. It’s a sleek and futuristic looking, high quality, beast that has a touch of sci-fi flare about it.

Emily Tyson

MSI GE63 Raider

If you’re looking to invest in your next work horse laptop for work or home use, you can’t go wrong with the MSI GE63.

Featured Content

Product Launch Showcase

Don’t have an account? Sign up here

Don't have an account? Sign up now

Forgot password?