Quick hack: Calendar Inviter

| 2 min read

Working in different organisations sometimes means having different email addresses and calendars. Currently I have two Outlook instances I have to manage (one for Bluefin and one for a client) on top of my Google-based personal calendar.

Keeping them in sync is a struggle that I avoid, but there’s recently been a specific case where I do want to make the effort, and that’s time / location scheduling – where I’ll be, on what days. This information needs to be in all calendars, to share with work colleagues, and for my own sanity (I see my Google calendar as my master instance in this case).

imageSo I wrote a quick Google Apps Script hack to allow me to quickly specify the where/when events in a particular Google calendar that I maintain (called “Work”), and then have those events distributed, via invitations, to my other Outlook identities. It’s not very sophisticated – all it does is look through the Work calendar for all-day events matching a certain title pattern, then look at the guest list; if the emails I want to share the event with are not already on the list, they’re added, and invites are sent.

Because of an issue with the CalendarService component of Google Apps Script (that’s been open since May 2011!) you can’t directly cause invites to be sent to new guests that you add to an existing event. So one workaround is to create the calendar invitation (ICS file) yourself and email it. It’s pretty simple (and Romain Vialard has an example in the commentary on the issue).

Actually creating the ICS file myself was a solution to not one but two issues. The ICS files that are auto-generated by Google Calendar when you add a guest via the UI contain entries like this for all-day events:

DTSTART;VALUE=DATE:20140305
DTEND;VALUE=DATE:20140306

Unfortunately Outlook makes an incorrect guess as to the timezone for these dates, based on its own timezone, and when the recipient calendar is in a different timezone than the originating event (in my case UTC and UTC+1), it causes the replicated entry to be skewed by an hour, causing the all-day event to span the wrong days! So being in control of the ICS content generation means I can be more explicit which in turn means that Outlook doesn’t get it wrong.

DTSTART:20140305T000000Z
DTEND:20140306T000000Z

So that’s it. I’ve made the script available as a Gist on Github and here’s a screenshot of some typical results.

image

Share & enjoy!