Importing email contacts with Ruby

ruby.jpgOne of any social application’s key aspects is often importing contacts. There are a couple of ways to do this. Many wrong ones, and one right one. Our friend Frank Oxener has pointed us to the best one yet.

The importing of contacts is nothing more than parsing a response from a webmail provider. Usually when you want to import contacts, people will build a parser themselves. I have always refused to do this. I don’t suffer from Not Invented Here and I always want to re-use existing code. Besides, I am not keen on parsing text. I have better things to do.

A step up from building everything yourself is using one of the many PHP libraries, or refactoring those. This works, but is brittle as well and introduces a dependency you are trying to avoid. For Bemba this solution was out, too.

A next step is to use one one of the free importer tools that companies are offering. Plaxo is one. Actually I kind of appreciate this route, and I use it for other projects. But for Bemba, we want to keep the user inside our own application. Also, privacy is a concern. Bemba does not exist to feed sensitive data into other businesses.

The step almost close to code nirvana is to use a professional library to do the scraping for you. We have gone this route with Bemba. There are a few tools out there that do all the parsing, scraping and error handling for you. This sort of works. Actually, it didn’t for us. The results from those scrapes were never completely to our liking.

Thanks to the weblog Holland on Rails, Frank discovered the perfect tool to import contacts. It is simply a Ruby gem that does all the hard work for you. Require it in your code, done! There is no step two. I have tested this library and it works wonders.

If you are building software in Ruby (on Rails) and need to import contacts from Yahoo, GMail or Hotmail, I can really recommend this library. It works!

8 Responses to “Importing email contacts with Ruby”


  1. 1 Steve Jan 17th, 2008 at 5:07 am

    Were you able to successfully implement all services with the gem? I’ve tried using it in the past and was only able to use it with Yahoo’s service.

  2. 2 joost Jan 17th, 2008 at 9:29 am

    Funny enough Yahoo is the only one that doesn’t work for me at the moment. GMail and Hotmail worked great out of the box. I’ve contacted the author about the Yahoo problem and hope to receive a response soon.

  3. 3 Stephan Kaag Jan 22nd, 2008 at 11:47 am

    Great gem indeed!

    When trying to use the gem out of the box, Hotmail did sometimes fail with a CSV::IllegalFormatError error.

    This fix worked for me -> http://rubyforge.org/tracker/index.php?func=detail&aid=13753&group_id=2693&atid=10371

  4. 4 shweta Feb 27th, 2008 at 2:20 pm

    hi,
    when i tried to install contacts gem ,it gives following error:

    ERROR: While executing gem … (RuntimeError)
    Error instaling contacts-1.0.9.gem:
    contacts requires json >= 0.4.1

  5. 5 joost Mar 12th, 2008 at 1:21 am

    For everyone trying the rubygem … as of early March it seems to lack updates. I have switched to using the (non-free) importer from Octazen which works great for all providers.

    http://bembamedia.com/2008/03/09/import-contacts-fixed-it/

  1. 1 Space Babies » Blog Archive » Importing email contacts in Ruby Pingback on Jan 14th, 2008 at 2:21 pm
  2. 2 Import contacts: fixed it! Pingback on Mar 9th, 2008 at 7:33 pm
  3. 3 links for 2008-03-11 « Caiwangqin’s delicious bog Pingback on Mar 12th, 2008 at 1:17 am

Leave a Reply




About Bemba Media

Bemba Media is a new social media company based in Amsterdam, the Netherlands. Founders Aaron Peters and Arne Dibbits are on a mission to offer people the easiest way to share their web experiences with friends and to discover what’s hot on the web right now.

The company launched Bemba.com in March 2008.

Bemba users share their favorite videos and websites on the social platforms they already use with their friends, like Facebook, Twitter and Hyves. More social networks and (micro-) blogs will follow.

Bemba will become a destination for 'funsurfing' the web, providing easy access to web content that people with similar interests have recently recommended to their friends.

Flickr photos

meeting with Sanoma NL in Hoofddorp #

Bemba blog in Wordle

More Photos

Twitter updates

    Recent readers