Outlook -> Office Online -> [insert icalendar hack here] -> Google Calendar -> Google Sync -> Blackberry

I have reason to want an exchange calendar sync’d to my blackberry. Problem being, the blackberry is not on that exchange server’s enterprise services and blackberry internet service doesn’t sync calendars.

Happily, Office Online offers the ability to publish calenders in an icalendar format. With Google Sync for Blackberry and Google Calendar I could subscribe and sync to my blackberry.

At some point, this broke.

Unhappily, it appears the Office Online feed has started failing in Google’s icalendar parser. It also fails in the iCalendar Validator by Steven N. Severinghaus.

Google has just released an Outlook add-in to sync calendars but I have restricted permissions to install software on my Outlook pc. So, I decided to try to solve this on my own.

Using http rather than webcal iCalendar Validator was able to flag the following:

Error: Error was: Error at line 68: Unparseable date: "2"

Looking in the feed, I found word wrapping breaking dates and guids:

EXDATE;TZID="GMT -0500 (Standard) / GMT -0400 (Daylight)":20090316T140000,2
0090323T140000

After finding other services that could parse the feed but none that would sync over the wire to my blackberry calendar, I wrote a short php script to make the feed comply with Google’s parser.

<?php
//request the icalendar file
$output = file_get_contents('http://[path to calendar ics file]');
//clean up the icalendar content
$output = preg_replace("/[\n|\r]+\t/m", "", $output);
//print out the result
echo $output;
?>

Now I can subscribe to the calendar via my script’s URL and google reads and syncs it to my blackberry. Happiness for now – at least until this kludge train derails again.

9 thoughts on “Outlook -> Office Online -> [insert icalendar hack here] -> Google Calendar -> Google Sync -> Blackberry

  1. You’re a genius! Just used this and was able to subscribe to my Outlook published calendar in Google Calendar. Thanks for taking the time to post this.

  2. This is what I have been looking for. I only have one option to make my work calendar visible outside of our company firewall: *.ics through Office Online. However, I need an Outlook client to subscribe. Also need to verify through Windows Live ID. I would like to subscribe in Google Calendar and on my iPhone, but whatever is fishy with the feed prevents this. Now I see there is one potential solution, but I fail to understand whare and how the script would be executed. Is that a one-off, or do you somehow integrate it into Google Calendar subscriptions. I am not a php guy, so I have no clue, but would be so happy to make this work…

  3. Thanks that makes things much clearer, and I see the logic. Now to the next thing. I guess you need to be able to publish your script to a public web site, so that Google can reach it.

    I wonder if it would work on the iPhone as well? Giving the URL to the script instead of the ical. Need to test this as soon as I get home from work.

    Great work finding this one out! I used the iCalendar Validator (on a downloaded *.ics file) and came to the conclusion that it was cluttered with erroneous line breaks.

  4. Instead of subscribing to the link provided by office online, you subscribe to your php script. When your client tries to read the calendar via the script to your URL, the script requests the exchange published ics file, filters it, and returns it to your client. Like any other http request to a dynamic script.

  5. The vcalendar file started failing validation again. Validator http://icalvalid.cloudapp.net/Default.aspx indicated the VERSION property was in the wrong place (not first). So I added this line to my php script to swap the PRODID and VERSION properties:

    $output = preg_replace(“/BEGIN:VCALENDARrnPRODID:(.*)rnVERSION:(.*)rn/m”, “BEGIN:VCALENDARrnVERSION:$2rnPRODID:$1rn”, $output);

    I then added a line to remove the custom extension properties since to simplify the vcalendar file for future troubleshooting.
    $output = preg_replace(“/^X-.*$n/m”,””, $output);

  6. So, just to confirm a detail – the script needs to be published on a page visible to the Google servers, correct? And that page’s URL is then provided to GCalendar, which then uses the script to pipe the data over, correcting as it goes?

  7. Folks…sorry about the dumb question…but I am a dumb blonde!
    Do I just copy this code into a blank file, save it with.php extension and upload to my webserver and point google to this? I tried that and it doesnt seem to work 🙁

  8. Hi,

    Three things:

    1. I haven’t used this solution myself in many months and so don’t know if the line wrap issue is still a/the problem
    2. You need to replace http://\[path to calendar ics file] with the actual URL to your ics file
    3. Your host has to support php

    When you browse to the php page on your host do you get a php error, some other error, or a blank page?

    1. php error should tell you what’s going on if you do a google search for the message
    2. some other error (or just the source splatted onto the page) makes me think your host doesn’t support php
    3. blank page – URL to the ics file?

Comments are closed.