My father lost his addresses on his laptop, and proceeded to import all his contacts from his Treo. Trouble was, none of the email addresses were showing up in Mail.app. Upon closer inspection, I discovered that Address Book had foolishly decieded that all these email addresses were phone numbers, and hence, they were not appearing as such.
Now how to fix this for over 500 contacts? ruby to the rescue! First, I created a smart group of cards whose phone number contained "@". These were the culprits. Next, I backed up Address Book's data, just in case. Then I exported all the contacts in this smart group to a vcard, and then deleted them. Then I wrote this little ruby script to fix everything:
new = File.open("vcards_fixed.vcf", "w")
File.open(ARGV[0], "r").each { |line|
if ((line.include? "item1.TEL;type=pref:") && (line.include? "@"))
new.puts "EMAIL;type=INTERNET;type=WORK;type=pref:" << (line.delete "item1.TEL;type=pref:")
else
new.puts line
end
}
new.closeruby fix_addresses.rb vCards.vcf
This assumes you exported the file as vCards.vcf, of course. The script goes through all the lines and changes the broken email addresses, and then writes a new vcf called vcards_fixed.vcf. Once you've run the script, import the new vcf to a (non-smart) group, and make sure everything is OK. If all went well, your email addresses will now work.
Mac OS X Hints
http://hints.macworld.com/article.php?story=20070403104653786