Previous Section  < Day Day Up >  Next Section

Hack 73. Import Your Contacts into Gmail

Data entry's a drag. Export your contacts from an existing web mail service, desktop email application, or database, and import them into your Gmail address book.

Possibly the most annoying aspect of moving into any new web mail home is bringing all your family, friends, and business contacts along with you. The average end user has almost been trained not to expect any sort of import utility, instead sighing and settling in for an evening of data entry.

Gmail, as with most post-1990s web mail applications worth their salt, provides the facility for importing all those contacts in just a few clicks; just how many depends on where you're exporting them from. Gmail accepts only one format: comma-separated values (CSV). Thankfully, CSV is about as low a common denominator as you could wish for; Yahoo! Address Book, Outlook, Outlook Express, Mac OS X Address Book (with a little help from a free application), Excel, and many other applications, web or otherwise, speak CSV.

Gmail's Help documentation on the subject of importing contacts is sure to keep up with the needs of its users, so keep an eye on "How do I import addresses into my Contacts list?" (http://gmail.google.com/support/bin/answer.py?answer=8301).


6.6.1. Anatomy of a Contacts CSV

First, a quick tour of a typical contacts CSV file as consumed by Gmail's import tool.

CSV files, as the name suggests, are little more than garden-variety text files in which data is listed one record per line, each field separated by (you guessed it!) a comma. The simplest of all contacts.csv files might then look something like this:

name,email

Rael Dornfest,rael@oreilly.com

Tara Calishain,tara@researchbuzz.com

...

The first line lists field names, in this case name and email address. Each line thereafter is a single person or entity (business, organization, etc.) in your contacts list with a corresponding name and email address.

Gmail accepts various formats of contact entry, recognizing some of the more common fields such as name, email address, phone, birthday, etc. Here's a slightly more detailed contacts.csv:

first name,last name,email address,phone

Rael,Dornfest,rael@oreilly.com,(212) 555-1212

Tara,Calishain,tara@researchbuzz.com, (212) 555-1213

...

Notice that name is split into first and last name fields, email is called email address, and there's a phone field too.

Unless you're going to be using Gmail as your main contacts database—and I can't quite see why you would—you don't need to import any more than name and email address (something akin to the first contacts.csv example) to find it useful.

In fact, at the time of this writing, Gmail does little with fields beyond name and email address but shove them into a Notes field.


6.6.2. Feed CSV to Gmail

Assuming that you have a CSV file to work with (if you don't, read on to the sections below for some guidance), importing is a snap.

From the main Gmail screen in your web browser, click the Contacts link (Figure 6-1) found at the bottom of the menu on the left side of the page.

Figure 6-1. Clicking the Contacts link gets you to your Gmail contacts


The Contacts page opens, listing all of (or none of, if you don't yet have any) your existing Gmail contacts. These may have been entered by hand, gleaned from incoming and outgoing mail, or imported at some earlier date. Click the Import Contacts link link at the top right of the page.

Click the Browse... (or equivalent) button when prompted to do so, as shown in Figure 6-2 and find your CSV file on your computer's hard drive. (Just what this looks like depends on your operating system and browser, but essentially you're just choosing a file much like you would from any application.) Click the Import Contacts button and—Bob's your uncle (that's "tada!" for my American readers)—you should see a confirmation that all went to plan and you've imported some number of contacts into your Gmail address book.

Figure 6-2. Finding that CSV file


Click the Return to Contacts link and you'll see your now fully stocked contacts list. Figure 6-3 shows mine, after importing the second sample CSV at the beginning of this hack.

Figure 6-3. Feeding that CSV file to Gmail


Delete any number of contacts by clicking their associated checkboxes and clicking the Delete Selected button. Edit a contact by clicking the appropriate [edit] link. Or type in a contact or three by hand using the Add Contact link.

Now, any time you start typing a known contact's name into the To, Cc, or Bcc field of a new message, Gmail will autocomplete it for you. No need to remember that cousin Adam is adamg@ozziesurfers.co.au or Auntie Joan is joan42@tepidmail.com.

6.6.3. Out of Outlook (Express)

Both Outlook Express and Outlook in Windows can export their address books as CSV.

In Outlook Express, select FileExportAddress Book..., choose Text File (Comma Separated Values) as your output format (see Figure 6-4), and click the Export button.

Figure 6-4. Export your Outlook Express Address Book as CSV


In Outlook, select FileImport and Export..., choose "Export to a file" and click Next, select Comma Separated Values (Windows) as your output format, and click Next again. An Export Wizard will then guide you the rest of the way to saving your contacts as a CSV file.

Feed either to Gmail as described earlier.

6.6.4. Hopping out of Hotmail

There are a couple ways to hop out of Hotmail with your contacts in tow. The first goes by way of Outlook Express or Outlook and the second using a touch of copy-and-paste, as suggested by the Gmail team in their online Help documentation.

6.6.4.1 By way of Outlook (Express)

As described earlier, both Outlook Express and Outlook are able to export to CSV. Both are also able to subscribe to Hotmail accounts and synchronize contacts therewith. Putting two and two together, you can use Outlook (Express) as an intermediary as follows.

Set up a new account in Outlook Express or Outlook, choosing HTTP as the server type and Hotmail as the mail service provider, as shown in Figure 6-5.

Figure 6-5. Setting up a Hotmail email account in Outlook Express


In Outlook Express, click the Addresses icon in the toolbar to open your Address Book. Select ToolsSynchronize Now (Figure 6-6) to synchronize your contacts between Outlook Express and Hotmail, thus bringing your Hotmail contacts to your computer.

Figure 6-6. Synchronizing with Hotmail to grab a local copy of your contacts


After a few moments of synchronization, your local Address Book will be up to date and you can export those contacts to CSV as described earlier in the "Out of Outlook (Express)" section.

6.6.4.2 By way of copy-and-paste

This is one of those ugly methods that you can't quite knock because it just plain works.

Log into Hotmail in your web browser of choice and select the Contacts tab, as shown in Figure 6-7. Click the Print View link in the Hotmail toolbar.

Figure 6-7. Click the Print View link in the Hotmail Contacts toolbar


In the Print View window that pops up, highlight everything (click and drag your mouse) from Name at the top left to the bottom most row in your list of contacts. Press Control-C or select EditCopy to copy the contacts, as shown in Figure 6-8.

Figure 6-8. Copying your contacts


Open Microsoft Excel, start a new workbook, select the A1 cell, and type Control-V or select EditPaste to paste in your contacts list. Your workbook should look something like Figure 6-9.

Figure 6-9. Pasting your contacts into an Excel workbook


Save the workbook as "CSV (Comma delimited)" (never mind the couple warnings about incompatibilities that Excel throws at you) and give the resulting CSV file to Gmail's import tool.

This turns into an unholy mess under Mac OS X. Contacts are not nicely spread across columns, leaving you with a row of contacts, empty cells, and some odd characters in any CSV file that you attempt to create.


6.6.5. Yumping from Yahoo!

Yahoo! Address Book exports directly to CSV.

Log into Yahoo! and visit your Address Book (the Addresses tab). Click the Import/Export link on the top right (Figure 6-10).

Figure 6-10. Using the Yahoo! Address Book's Import/Export feature


On the Export section of the resulting page, click the Yahoo! CSV Export Now button (Figure 6-11).

Figure 6-11. Exporting as Yahoo! CSV


Your browser will most likely prompt you for a place to save the CSV file on your computer's hard drive, as shown in Figure 6-12.

Figure 6-12. Saving the exported CSV file to your hard drive


Now, go ahead and import that CSV using the Gmail import tool, described earlier.

I do apologize for the bad "Yumping" pun, but "Yahoo!" doesn't leave you much room for alliterated action verbs: yodeling? yanking?


6.6.6. Moving from .Mac

The Mac OS X Address Book only exports to something called vCard, which is understood by many contacts applications, but not by Gmail.

Thankfully, someone's written a magical little app to help. AddressBookToCSV (http://homepage.mac.com/kenferry/software.html#AddressBookToCSV; freeware) slurps up all of your contacts—name and email address only, which is nicer to my mind than uploading a slew of data unnecessary for your Gmailing needs—out of Address Book and spits them into a CSV file that you can feed to Gmail. Download the app, mount the .dmg on your desktop, and run it right from there, as shown in Figure 6-13. (If you'll likely use it again and again, go ahead and drag it into your Applications/Utilities folder.)

Figure 6-13. AddressBookToCSV exports Address Book names and email addresses to CSV


When prompted to do so, choose a place to save the contacts.csv file and click the Save button. Close the application using Command-Q (it doesn't do so by itself when done).

Feed contacts.csv to Gmail as usual.

6.6.7. Hand-Crafting a CSV

If your contacts exist in some form with no obvious path to CSV, you can always export them in any way you can, arriving at some point at either a plain-text file that you can manipulate by hand—tedious, but possible—or something Excel can read. If you can get to Excel, you can get to CSV; massage the data into a form similar to that discussed at the top of this hack, select FileSave As... and save as "CSV (Comma delimited)."

6.6.8. Last-Ditch Effort

If, for whatever reason, you can't massage your contacts into CSV form or use Gmail's Import Contacts tool, there is a (admittedly grotty) way to get all your contacts to Gmail using email itself.

Send out a single email message (preferably one that announces your intention) to (on the To: line) your Gmail account (or one that forwards to your Gmail account), copying all your contacts on the Cc: line.

You should probably batch these such that there's some semblance of privacy, with your family not seeing all of your business associates' addresses and vice versa. Send a separate message for contacts of a sensitive nature.


When you receive that message at Gmail, open it and choose "Reply to all." Write something explanatory again and send it off.

Gmail automatically adds to your contact list the names and email addresses of the people you send email to from Gmail, so you've just added all of those people to your Gmail address book.

Again, this is a rather annoying way (annoying to your friends, family, and business contacts) to get your contacts list to Gmail, so it should be regarded as a last-ditch effort.


Rael Dornfest and Justin Blanton

    Previous Section  < Day Day Up >  Next Section