Visual FoxPro and MS Outlook Automation to the Rescue
After I first heard about
O2 Atom Life supporting
Windows Mobile 6.0, I really wanted to upgrade my
O2 Atom Life’s operating system to Windows Mobile 6.0 but never found the time. To cut to the chase, I did have some slack time last Wednesday and proceeded with upgrade process.
In order to back-up the contacts on my
O2 Atom Life, I used ActiveSync 4.5 to sync my contacts to a new and empty
MS Outlook 2003 profile. Before all of you raised your collective eyebrows on my move, let me say the following: I don’t sync the contacts in my O2 Atom Life and my
MS Outlook 2003 profile. I only sync the calendar and tasks. After successfully pairing my O2 with the new and empty
MS Outlook 2003 profile I proceeded to sync the contacts only. So with all the contacts from my O2 safely transferred to the MS Outlook, I followed the steps in O2’s website in upgrading my operating system to Windows Mobile 6.0. The upgrade process went without a hitch. So now after doing the usual settings on my O2 after the upgrade, I sync’d it with MS Outlook profile which contained my contacts. Again like a charm my contacts are now in my O2 sporting the
Windows Mobile 6.0 operating system. Now I wanted to sync my calendar, so I close MS Outlook and opened it again this time using my usual profile and bam it hit me, I need to un-pair my O2 with the new profile and then pair it with the my usual profile. No big deal right, but since I don’t sync my contacts (with my usual profile and O2) only the calendar and tasks, I need to remove the check mark on the sync options for the contacts but by so doing effectively deleting all the contacts in my O2. So now I was in a dilemma. What should one do in such a predicament? Well, when things can’t be done using the software itself, I turn to my expertise in
Visual FoxPro (VFP) and automation of MS Outlook. So here are the steps I took:
- I opened MS Outlook with the new profile containing the contacts from my O2 Atom Life.
- I ran a snippet of VFP code to extract all the contacts and save these as individual VCard files (extension .vcf).
- Send the VCard’s from my laptop to my O2 Atom Life via Bluetooth and viola all my contacts were transferred to my O2 Atom Life.
The
Visual FoxPro code snippet I used is found below:
lnContactsFolder = 10
lnVCardType = 6
loOutlook = Createobject("Outlook.Application")
loNamespace = loOutlook.GetNamespace("MAPI")
loContacts = loNamespace.GetDefaultFolder(lnContactsFolder).Items
For Each loContact In loContacts
lcName = loContact.FirstName + loContact.LastName
Wait Window "Saving: " + lcName Nowait
lcPath = Forceext("C:\temp\" + lcName,"vcf")
loContact.SaveAs(lcPath,lnVCardType)
Next