Editing your "Previous Recipients" database

Overview

The OSX Mail app maintains a list of all the people you have ever sent an email to and uses to autocomplete addresses. It populates it automatically and based on the "reply to" addresses of emails as well as any new names you use. The Mail app itself allows you to remove entries (Mail -> Windows -> Previous Recipients) but does not allow editing. This is annoying since often the database contains rather poorly formatted names. Making minor edits is fortunately not difficult by using the firefox plugin "Sqlite Manager".

Editing

The previous recipient list is an sqlite3 database and is stored in the location ~/Library/Application\ Support/AddressBook/MailRecents-v4.abcdmr i.e.in your home space Library (which may not be visible in the finder window). Before editing you should make a copy of this file in case of trouble.

Install firefox if you have not already done so, and then install the firefox plugin SQLite Manager. After restarting firefox the new application is under Tools. Then you 'connect' to the database file. Navigate to the database you wish to edit - note that by default the Manager only displays files ending in .sqlite so you will need to show "All Files". To edit entries, make sure you are using the "Browse & Search" tab and then on the left hand panel select "Tables (4)" -> "ZABCDMAILRECENT" which will show the first 100 entries. You can navigate or search to find entries. Double click an entry to edit. It is pretty obvious what the necessary fields are to edit (ZFIRSTNAME, ZLASTNAME etc). The "normalized" versions seem to be lower case versions which you need to do by hand. It asks for confirmation before running the database replacement command. Simply close the database at the end - it is edited live so all changes are saved immediately.

Adding Entries

I have not yet found an easy way to do this (other than sending them an email!).

Exporting to csv

Exporting the data is straightforward and documented in many places on the web. OSX comes with command-line sqlite3 so you can simply run the command (all on one line):

sqlite3 -csv ~/Library/Application\ Support/AddressBook/MailRecents-v4.abcdmr 'select ZLASTNAME, ZFIRSTNAME, ZEMAIL from ZABCDMAILRECENT;'>recent.csv

This will create the a comma separated value list (called recent.csv)

As ever, any use you make of these instructions is done entirely at your own risk.