Import Mail's Recent Contacts into Address Book

May 02, '08 07:30:01AM

Contributed by: Anonymous

I needed to find a quick and dirty way to put all of Mail.app's stored email addresses into my Address Book. It turns out that these are stored in a SQLitev3 database named MailRecents-v4.abcdmr in ~/Library » Application Support » AddressBook/. To import these into Address Book's contact list, all I needed to do was this:

  1. Install SQLitev3 (sudo port install sqlite3 if using MacPorts)
  2. Dump the contents of the recents table to a text file with this series of commands in Terminal:
    $ sqlite3 ~/Library/Application Support/AddressBook/MailRecents-v4.abcdmr
    sqlite> .separator ,
    sqlite> .output /path/to/outputput/file/Recents.csv
    sqlite> select * from ZABCDMAILRECENT;
    sqlite> .exit
  3. Now use Address Book's File » Import function to import the newly-created Recents.csv as a text file. You will be prompted to choose which fields to import as what, with the first/last names and email addresses from your recents available.
[robg adds: While this hint worked as described, there are a couple of things that strike me as overly complex about it. First, the easiest way to get all your recent contacts from Mail into Address Book starts in Mail. Select Window » Previous Recipients, press Command-A when the new window appears, and then click Add to Address Book. However, you won't get any control over what happens using this method, so perhaps you'd like to try the method in this hint. If so, sqlite3 is installed by default in 10.4 and 10.5 (it's in /usr/bin), so step one shouldn't be required. In the end, I'm not really sure what advantages this method may offer over the built-in solution, but it is interesting to see the structure of the recent contacts file in sqlite3.]

Comments (1)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20080501064538995