182 Part III — Conquering Gmail
Here is an example of a very simple vCard file:
BEGIN:VCARD
VERSION:3.0
FN:Ben Hammersley
EMAIL;type=INTERNET:[email protected]
END:VCARD
Saving that to disk and importing it into a vCard-compatible program will result
in my lovely e-mail address being embedded into your system. vCard files can
contain more than one vCard within, and that’s what the script in Listing 12-3
does. It’s very, very simple. It opens up a filehandle to a file called contacts.vcf
in the directory you’re running the script in (change that line to make it go else-
where, naturally), and then calls upon the Mail::Webmail::Gmail module to
provide a hash of the contacts in your Contacts list. It then just iterates through
them, creating vCards as it goes and printing them to the filehandle. Then it
closes the filehandle and exits. Simplicity itself, really. You can then go on and
import the large vCard file into your weapon of choice.
And Now
In this chapter, you looked at dealing with contacts within Gmail. You should
have learned how to import contacts from other applications. You should also be
able to export them at will, in order to re-import them into other applications or
for backup purposes. In the next chapter, you look at scraping the Gmail interface.