Exposing SharePoint calendars for iCalendar clients

Hello there,

since Sharepoint offers out-of-the-box calendar and scheduling capabilities, it is a nice option for teams in terms of improved collaboration and sharing common agendas. By default, users can access the MOSS calendars using a browser or by syncing it with their Microsoft Outlook clients. Additionally, a RSS subscription is also available.
So far, so good, but if we need to subscribe to the calendar using a Mac or an iPhone, iPad, or any other client supporting the iCalendar specification, we have to use a custom solution.

Simply put, a file with the content type text/calendar needs to be generated, and it has to more or less comply with the RFC 2445 specification. Of course you may want to implement it your way from scratch, but there’s a nice iCal Exporter kit from CodePlex. It has been developed as a MOSS feature, but you can easily adapt it to serve users in a different way, for example as a custom http handler. So one can create a class inheriting the IHttpHandler interface, deploy the class library onto the Sharepoint application, and register the handler in web.config:

<add verb="GET,POST" path="*/ical.ics" type="MyLibrary.MyIcalHandler" />

Then we could access the generated file for example via http://myhost/mysite/lists/calendar/ical.ics , and subscribe to the calendar in a corresponding client software. In the handler itself, based on the request URL, we can fetch the corresponding Sharepoint list, iterate through its items and generate the proper entries, then flush it to the browser. The iCal Exporter kit also deals with recurring calendar entries, deleted event series’ occurences, all-day events, so that almost every case is covered.

One thing worth mentioning: when generating an event entry, be careful using the DTSTAMP property. In order for iCal clients to properly recognize changes made to calendar entries, one has to assign the last-modified-date property of the corresponding SPListItem as DTSTAMP value:

 foreach (SPListItem item in calendarList.Items)
    // write vevent start...
    DateTime modified = Convert.ToDateTime(item["Modified"]);
    String dtstamp = "DTSTAMP:" + modified.ToString("yyyyMMddTHHmmssZ");
    // write dtstamp, other properties, vevent end

Otherwise you may encounter a problem that the client won’t fetch a calendar entry’s changes.

Hope this helps,

10 myśli nt. „Exposing SharePoint calendars for iCalendar clients”

    1. Hi, yes, I’ve done it this way. It’s been in production environment for half a year now, and it seems to be doing its job well as a read-only solution.


  1. Hi Lukasz,

    which Sharepoint version are you using? Unfortunately I already fail activating the iCal exporter kit and I think this is because it was designed for Sharepoint 3.0 and not 2010. We are running Sharepoint Foundation 2010. Any ideas?

    Greetings, Max.

    1. Hi Max,

      thanks for your suggestion. Indeed, my post was based on experiences with MOSS 2007, WSS 3.0. I can imagine the iCal Exporter Kit hasn’t been updated for a while and it may not be compatible with SP2010.

      However, the logic behind it was quite simple – querying (calendar) list items and parsing their properties in order to write it to a file. As far as I can remember, the Kit from Codeplex came with source code. Maybe you can find the reason for incompatibility there? And/or override the item parsing logic in order to adapt it for SP2010?

      Cheers, Łukasz

  2. Hi, I have been trawling the internet for an answer to a calendar based query. I’m looking for a reverse of the above. Something to read in an .ics file to SharePoint 2010. Has anyone come across anything? We have a number of external, currently incompatable systems which export an .ics file I would love to be able to overlay into SharePoints calendar!

    1. Hello Hannah,

      well, the first thing comes to my mind is to read and parse the ics file (there are some libs that can already do that, like this one. After that it’s all about generating/modifying list items in the proper calendar list of Sharepoint.


  3. Good Post.. thanks for sharing this idea. We are in fact in the process for developing something similar to add a new button on the Ribbon to all Mac Users to subscribe to a SharePoint 2010 Calendar and the idea to use HTTP Handler to generate iCal on the fly is a good one.

    1. @prashantganesh — Did you guys ever finish creating the SharePoint 2010 port with an extra Ribbon button? This is really important in our school environment.

  4. I was able to ghet the ical installed and working. Can you please provide detailed step by step instructions for deployin the class library onto the Sharepoint application, and register the handler in web.config? I am looking to provide this ics for importing via url.

    1. @Simernet: you’d have to deploy your class library to bin folder of the app or GAC, then register the http handler in web.config as written in my post above.

Dodaj komentarz

Twój adres email nie zostanie opublikowany. Pola, których wypełnienie jest wymagane, są oznaczone symbolem *