exchange2ical available on CodePlex

The Exchange-to-iCalendar script that I mentioned here is now published to CodePlex. It’s intended for organizations that run Exchange and would like to publish selected calendars in iCalendar (aka iCal, or .ICS) format without having to rely on a client machine running Outlook 2007.

I’ve never run a real Exchange server, so I’m wide open to suggestions as to how to actually publish the ICS file created by this little IronPython script. Right now, it just emits that file. For user Jon on Exchange host Zanzibar, you would do something like this:

ipy Zanzibar Jon > jon.ics

There are lots of ways jon.ics could get pushed to a web-accessible location, but I’m not sure what the default should be, or whether to do a filesystem operation, or an FTP transfer, or something else.

My idea is that you’d schedule this command to run on a regular basis, and that it would run under an account that has the necessary privileges to access the specified user’s calendar. But again, I’m not an Exchange admin, so if that sounds like the wrong thing, let me know what the right thing would be.

As for the iCalendar output, this script currently does the Simplest Thing That Could Possibly Work. It doesn’t, for example, try to “fold” long lines in the output (e.g., event summaries and unique IDs), which I gather the spec recommends but does not require.

There’s only been minimal testing. I’ve run it against a couple of different Exchange servers (2003 and 2007), validated the ICS output using this handy validator, and verified that the resulting files — containing both individual and recurring events — can be successfully imported, or subscribed to, in Outlook 2007, Google Calendar, and Apple iCal.

If you have a need for such a thing, try it and let me know how it goes.

11 thoughts on “exchange2ical available on CodePlex

  1. Jeffrey Harris

    This looks like it should work, this is the first interesting IronPython project I’ve seen.

    As the author of a Python iCalendar library I suppose I ought to want you to use one, but I think Simplest Thing That Could Work is a better plan. It’s nice not to have to deal with Python dependencies.

    I will note that since all your times are UTC, RRULEs aren’t going to work around DST transitions. But I’m not sure if Exchange gives you any reasonable timezone information, so fixing that problem would definitely be a pain.

    Note that the “iCalendar validator” doesn’t actually do any validation, it just makes sure your file parses in iCal4J. The two are closely connected, but not quite the same thing. It tolerates some illegal things some calendar clients won’t, like the absence of a UID in VEVENTs, for instance.

    Reply
  2. Jon Udell Post author

    > RRULEs aren’t going to work around DST
    > transitions.

    Hmm. Yeah, that whole subject is deeply scary to me.

    There’s surely more that can be done with the SQL / WebDAV, so far I’ve only cribbed from examples I could find. I’m hoping this will attract folks who know more about it and who can chime in.

    > It tolerates some illegal things some
    > calendar clients won’t, like the
    > absence of
    > a UID in VEVENTs, for instance.

    Thanks for the tip. Is there a stricter validator?

    While I’ve got you, do you have an opinion on punting the line folding?

    Reply
  3. Jeffrey Harris

    I think punting on line-folding is totally fine. I’ve never heard of a calendar client caring. They can’t, really, because folding at 75 characters is a SHOULD, which means it’s optional, not required.

    Right now I’m having trouble getting Codeplex to let me browse the source code, it keeps sending me to the license agreement page then back to the source code index (it did that yesterday, too, but it worked once).

    My memory, though, is that you aren’t backslash escaping text in your SUMMARY, which is required for TEXT. Most calendar clients will tolerate the lack of escaping, but not all. Lone commas, for instance, may cause a parser to ignore everything after it.

    Reply
  4. Kumar McMillan

    fwiw, the Entourage client for Mac OS X, which is surprisingly decent, has an option to “synchronize with ical.” I tried it out and it actually worked. I could view my exchange calendar in ican *and* I could edit it in ical and the changes would be recognized by exchange. However, I upgraded something once and then saw duplicate events in the ical view of my calendar. I decided to stop using the sync then but more so because I kinda liked the Entourage calendar interface. So the sync definitely has quirks and of course requires you to purchase Entourage for mac. But if your company has already bought Exchange Server, the Entourage license cost is a laughable jingle of change :( Seriously, Exchange Server is not cheap.

    Reply
  5. Günter

    Hi Jon,
    as a co-author of ReminderFox I was interested in migrating Outlook calender info to iCalendar/ICS format.
    Because ReminderFox is an extension the the Mozilla world there is no access to the OL internals from within an extension.
    I ended up with some some Jscript/HTA coding to access the local OL-Calendar and the OL-contacts to generate ICS a file including VEVENTS and VTODOS (with some limitation as with RRULE) and with a LDIF file compatible with the TB/AB import.
    Note: this doe’t access the Exchange server but the local PST file.

    All that works well. You can access the script with some documentation etc at:
    http://reminderfox.mozdev.org/utilities/PIM_escapeOL.zip

    The trade-off of that solution: the HTA is threaded as SPAM with some Mail Services when sending it as an attachment.

    So my Question:
    Do you see another way to handle those JSCRIPTs and build a utility/standalone prog which doesn’t get problems with the Mail Servers?

    Note: I don’t have any knowledge about Python :(

    Reply
  6. Rajnish

    How do I run this remotely? My exchange server is hosted by a service provider. I need to provide some credentials to login. Thoughts??

    Reply
  7. Jon Udell Post author

    > I need to provide some credentials to login.

    As written, it uses your current Windows credentials. So if you run it from a logged-in PC, and your credentials are good for the Exchange server, it’ll work.

    Reply
  8. Mike

    Jon, this is exactly the sort of thing I’ve been looking for. We are a public school district using Exchange 2007. I have resource calendars and shared calendars set up for various things. I wanted an easy way to publish the calendars to our webpage. I can publish personal folder calendars to WebDAV easily with Outlook, but not shared calendars. I can then view our School calendar, lunch calendar, etc using phpicalendar on the website and use the rss feeds it generates to display the info in different ways on our homepage.

    I installed Iron Python and downloaded your script, but I’m having some trouble getting it running. When I run:
    ipy exchange2ical.py server user > user.ics
    I get:
    File “exchange2ical.py”, line 96 in exchange2ical.py. AttributeError: ‘type’ object has no attribute ‘CreateArray’

    Am I missing something obvious? Thanks for your work on this!

    Reply
  9. Jon Udell Post author

    I’ve been waiting for somebody to actually try using that script! :-)

    Checking into it now. Feel free to contact me directly at jonu@microsoft.com.

    Update: The script works as-is with IronPython 1.1, which was current when it was written. But not in IronPython 2.0.

    If you change from this:

    bytes = map(ord,list(query))
    bytes = System.Array.CreateArray(System.Byte,bytes)

    to this:

    bytes = System.Text.Encoding.UTF8.GetBytes(query)

    It works (for me, at least, on a VPN connection to my Exchange Server) in IronPython 2 as well.

    Please let me know if this helps.

    Meanwhile, having since learned a lot more iCalendar, and having used the DDay.iCal component for the elmcity project, I’m going to revisit this. I should probably use DDay.iCal to generate ICS more reliably than the ad-hoc way that script does it.

    Reply
  10. Pingback: But will it include calendars? « Kassblog

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s