See if I'm online.

Feature Story : Torturing Myself With Tech: Syncing Sunbird and Outlook
Published 07 Jun 2005 ~ revised 24 Jun 2005

In an effort to become even more interconnected than I already am, I recently spent some time trying to make my calendar (both personal and work) portable. By portable I mean easily updateable, and interoperable among scottahearn.com, my work computer, and my Pocket PC (PDA).

The problem is how to deal with different platforms and differnt software? After months of not even using a calendar for work and using a tab-delimited, custom-made PHP parser for my personal calendar (here on my website), I decided on iCalendar, a standardized calendar format used by Apple's iCal software. Hmmm, I don't run Apple. Here's what I was faced with:

Work Laptop & Software:
IBM Thinkpad T41
Windows XP Professional (5.1, build 2600, SP2)
Outlook 2003 (11.6359.6408) SP1

PDA
HP iPaq 5455
Microsoft Pocket PC, 3.0 build 11178
Windows CE 3.0 (ROM 1.11.19.ENG)

Having decided to use the iCalendar standard ("If it's standard, everyone will use it, right?"), I needed something to easily manage dates and events. Enter Mozilla Sunbird, an open-source solution that supports iCalendar! Okay, easy - I manage my calendar(s) in Sunbird, throw them on my website using PHPiCalendar, and subscribe to cool shared calendars using iCalShare.com. Then, I can include my work calendar in all that, export my calendar(s) from Sunbird and import them into Outlook (thereby allowing me to use reminders and such at work and on my Pocket PC; all Outlook and Microsoft, obviously).

Oh, but no. Outlook throws an error when trying to import an exported Sunbird .ics file.

I suppose I could maintain my calendars exclusively on Outlook, then export from that to Sunbird. But Outlook is proprietary, and I like f-r-e-e better.

So what to do? Figure out why Outlook bombs on import, of course! Oh, it's easy: Sunbird includes some "MOZILLA"-specific entities in their export, and rather than ignore them, Outlook simply says "the import file may be corrupt." Further, if you import just one entry, Outlook will take it; but try to import a batch of entries, it will fail. Strangely, though, if you simply remove these Mozilla tags, Outlook suddenly recognizes the .ics file!

So, below is the extremely convoluted process I must go through in the name of geekiness and open-source-software devotion:

  1. Export from Sunbird:
    • Keep in mind Sunbird's export is seriously broken with the current [0.2] release. This includes how to export calendars, and export formats such as XML and CSV.
    • Select one or many calendars, then Edit - "Select All".
    • File - "Export Selected Events..."
    • File - "Save As...", "Calendar Files"
  2. Strip out Mozilla entities using script below. Perl to the rescue!
  3. Import into Outlook:
    • File - "Import and Export..."
    • Select "Import an iCalendar or vCalendar file", select processed file from script
  4. ActiveSync. Celebrate.
#!/usr/bin/perl
$events = `cat MozillaCalEvents.ics`;
while ($events =~ s/X-MOZILLA-ALARM-DEFAULT-LENGTH.*?\n\s\:0.*?\n//g) { }
open(OUT, '> MozillaCalEvents.out.ics');
print OUT $events;
close(OUT);

Update, 24 Jun 2005: Forget it. I found another export bug with Sunbird, and decided all the effort simply isn't worth it. I'm now using Outlook as my "master," and am able to export to iCal format (for use here on scottahearn.com) using a great macro utility called outlook2ical. It even lets me maintain iCal categories. I'm sad the open source solution is so badly flawed, but this is ultimately better for me and my Pocket PC.