![]() |
|
Do you know where your variables are? | |
PerlMonks |
Adding Outlook Contacts In Perlby jgamble (Pilgrim) |
on Feb 07, 2007 at 19:42 UTC ( #598865=perlmeditation: print w/replies, xml ) | Need Help?? |
I had a emergency call to transfer address book contents from a client's old system to Microsoft Outlook. At first this seemed simple. The old system exported its contents in a well-formed VCF file, each vCard separated by a double newline. But Outlook assumes that each VCF file holds only one vCard, and imports only the first entry, skipping the rest. That's simple (I thought). Set $/ to "\n\n", slurp in the file to an array variable, and write out each record as an individual file in a subdirectory for each user. Oops. Not so simple. Outlook doesn't do batch reads of VCF files. Someone would have to click on over a thousand VCF files to enter them into Outlook, and since that someone would be me it was vitally important to come up with a different solution. A search through Google showed this to be a problem that almost no one had bothered to solve. But I had written an Outlook e-mail subroutine once, and thought it could be modified to handle contact items instead of mail items. Here's the outer loop around the new subroutine. At this point the records have been slurped into the array @vrecs. I ignored groups, which were done in an idiosyncratic way in the old system. Some vcard items cross multiple lines, so I temporarily join them. Then I split the entries by newlines, and created a hash to feed to outlook_vcard().
Since the outlook_vcard function was written to handle a specific problem, not all possible VFC entries are dealt with. For example, a quick search of the client's files showed that only one e-mail address per entry was present, so I didn't have to worry about dealing with multiple e-mail addresses, something that wouldn't be true in a more generic application.
Back to
Meditations
|
|