I seem to be in competition with those good folk down at CSIRO Land & Water. I have a counterpart down there who, like me, develops web applications but sits outside of IT. The difference is that he uses ASP.Net and oftens buys web components while I am a PHP person who makes do with freely available open source.

Land & Water appear to be quite good at promoting their web applications which gives our senior bosses a case of the "want me's". Today it was the ability to export events from the intranet to Microsoft Outlook. Thankfully there's an open standard for sharing calendar information between Outlook and other calendars (such as Apple's iCal). It's called iCalendar.

The iCalendar standard (RFC2445) is typically dense, but Shu-wai Chow has provided a clear guide to generating iCalendar output using PHP. Note that the CRLF hex substitution should be =0D=0A and not have a terminating =.

I had a lot of trouble getting Outlook to accept the generated ics file. I kept getting the following error:

"Microsoft Office Outlook cannot import vCalendar file. This error can appear if you have attempted to save a recurring Lunar appointment in iCalendar format. To avoid this error, set the appointment option to Gregorian instead of Lunar."

It turns out that this is Outlook's generic answer for iCalendar importing problems. Maybe it was the wrong time of month for the programmers and as usual Outlook does not completely support the standards. At a minimum, the ics file should contain this content.

In the end the problem turned out to be an additional carriage return. My code read something like:

} else {

I fixed this by changing the code to read:

END:VCALENDAR<?php } else {

It solved the problem and tincaCMS now supports exporting events in iCalendar format. Not bad after only two hours sleep!