Syncing calendars

Time management is almost crucial in today’s hectic life. Meetings and appointments flow into the calendars and managing the valuable time has become more than important. Many electronic time management systems help us to keep track on everything. The unfortunate development is multiple calendars located on the net as well as on the corporate network to host appointments at the workplace. People like me use online calendars, such as Google Calendar to manage private events. Thanks to modern smart phones, like my Samsung Galaxy S, I can easily manage my time no matter how many separate calendars I need to update. My workplace calendar runs on Outlook platform. I could use this calendar on my smart phone as well, but I like to sync events from Outlook to my Google Calendar so that I have only one instance of my appointments.

I set up Google’s Outlook syncing application on my laptop one day. Everything ran smoothly until this Tuesday. I was planning an appointment in the evening but noticed that a meeting I booked earlier was not showing in my Google Calendar. Luckily I remembered that appointment to avoid overlapping events. Next day I started to dig into this problem and found that Google Calendar Sync app had stopped working and in fact was asking me to sign in the online calendar to refresh my session. The actual error code was the famous number 2016. I signed out and back in my online calendar but syncing was not copying some events from my Outlook calendar to my online one. I kept reading forum postings and finally uninstalled and reinstalled the Google Calendar Sync application. Now, new problems arose.

I couldn’t sign in the Google Calendar Sync application because of wrong username and password combination. I read on the forum moaning and even tried to change my Google password. That didn’t help either. I finally found an answer I had totally forgotten. Google Sync application needs the secondary password, not the account password to sign in from my computer. This is due to my double security settings on the account. I rushed to enter that password and syncing started to work only to let me know that some appointments were still missing. They were showing up in my Outlook calendar but not syncing to my online calendar. I returned back to the drawing board and continued studying the calendar help forum posts until I found one very interesting solution I wanted to try.

It appeared that the syncing application syncs only IPM.Appointment classified items from the Outlook calendar. I checked one of the problematic items and learned that it had "IPM.Appointment.Live Meeting Request" as the MessageClass thus preventing the sync application from sending it to my online calendar. I launched the VBA editor and in the immediate window quickly manipulated the MessageClass value changing it to just "IPM.Appointment". Right after having saved the changes I initiated the sync process and found that the event eventually appeared in my Google calendar. This seemed to be the solution to solve the mystery of missing appointments after syncing. The next step was to code a little Visual Basic script to always change the appointment message class automatically after I receive it in Outlook. The following VBA script for Outlook 2007 does the trick.

Option Explicit ' Synchronization object that fires each time ' Outlook starts syncing the folders Public WithEvents mySync As Outlook.SyncObject Private Sub changeMessageClass()   Dim calendarItemsFolder As Outlook.folder   Dim apt As Outlook.AppointmentItem   Set calendarItemsFolder = Application.GetNamespace("MAPI") .GetDefaultFolder(olFolderCalendar)   For Each apt In calendarItemsFolder.Items     If (apt.MessageClass <> "IPM.Appointment") Then       apt.MessageClass = "IPM.Appointment"       apt.Save     End If   Next End Sub Private Sub Application_Startup()   Set mySync = Application.Session.SyncObjects.Item(1)   mySync.Start End Sub Private Sub mySync_SyncEnd()   changeMessageClass End Sub

In case you like to implement this feature in your Outlook application first start the VBA editor by pressing simultaneously Alt+F11. Select ThisOutlookSession from Microsoft Office Outlook Objects in Project1 tree. Copy and paste the code into the code window and save. You may need to set up local security to run Visual Basic scripts (macros) even created by you. Create a personal digital signature to prevent Outlook from displaying macro security warnings for your own scripts. Outlook performs so called folder syncing periodically to fetch new email messages, for example. You can adjust how often Outlook syncs the folders in application options. Each time the folder syncing is about to end Outlook will call mySync_SyncEnd() subroutine, which in turn calls changeMessageClass subroutine.

Final words

If you find your Google Calendar Sync application sitting idle with an error message and waiting for you to sign in again, remember to first offer the secondary Google application password instead of your main Google account password. Some items may not sync from Outlook calendar to your Google calendar because of the MessageClass value, which should be "IPM.Appointment" for Google sync application.

Julkaistu Wednesdayna 5.10.2011 klo 18:33 avainsanalla ohjelmointi.

Maistuva makkarakeitto
Iron Sky -sarjakuva