Creating Outlook Calendar events through hyperlinks

You mightn’t think it was possible, the lack of implimentations you see for it on a day-to-day basis, but actually you can create Calendar events for a wide range of email / organiser clients using the iCalendar file format.

From the users’ point of view, your Calendar event appears as every other hyperlink does in your html pages – but when they click on the link, instead of being taken to a new page, Outlook opens up an ‘add event’ just as if they’d clicked on a meeting request (in Outlook).

From the developers’ point of view, once you have your server configured correctly, it’s just a case of creating and linking to an .ics file instead of a .htm file – at which point the client’s email software should take over.

Does it work for me?

I don’t know – try clicking on this link.  If MIME types are incorrectly set you’ll probably see a plain text file, and if you don’t have an application setup that’s compatable with iCalendar events, you’ll probably just be asked to save the file to your hard drive.

How do you create a Calendar event then?

First up, you need to sort out your MIME-types.  I’m not going into that because it can get a little too complex, but just make sure you have the file extension .ics registered under the MIME-type “text/calendar” – if you’re lucky it might already be setup!

Next, you need to make the actual file, which is simple in one sense and complex in another.  iCalendar files are plain text files, so you just need notepad or something to create them, but they do have a very specific format. Wikipedia has a very simple example, so we’re going to use that as a basis for our sample file.

So lets create a working example – and we’ll use the Flash on the Beach conference as a basis.

This is the example on Wikipedia;

BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//hacksw/handcal//NONSGML v1.0//EN
BEGIN:VEVENT
DTSTART:19970714T170000Z
DTEND:19970715T035959Z
SUMMARY:Bastille Day Party
END:VEVENT
END:VCALENDAR

The framework we need to keep is pretty self explanitory – there’s elements like the beginning and ending of portions of the file, and a basic framework for the dates and summary.  According to the RFC iCalendar specification, VERSION and PRODID are both required, so we’ll leave those in also – which just leaves us with some customizing to do on the dates and summary information;

BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//hacksw/handcal//NONSGML v1.0//EN
BEGIN:VEVENT
DTSTART:20080928T000000Z
DTEND:20081001T000000Z
SUMMARY:Flash on the Beach 08 Conference
DESCRIPTION:Flash on the Beach 08 is here again!
Wow, Flash on the Beach is in it's third year already! FOTB06 was awesome,
FOTB07 was even better, and we are now pulling out all the stops to make
FOTB08 the best yet! We have the best talent around speaking, new speakers
to FOTB, the Inspired Sessions, workshops, parties and more! It's gonna rock!
END:VEVENT
END:VCALENDAR

You can see that there’s practically no special formatting for the actual content – just plain text.  (Which is a shock after working with XML and CDATA for so long.)  And date formatting is just a condensed string – 1/11/2008, 15:30:00 just becomes 20081101T153000Z.

Whack that into notepad, change the file extension to .ics and you’re away!

That’s it?

That really is it. It’s an incredibly easy thing to customize – I’d really recommend you skim through the spec for iCalendar if you’re thinking of doing more clever things – there’s formats and properties that control priorities, due dates, durations, status, alarms, journal entries – practically everything that Outlook does (beyond emails) can be done with the iCalendar format.

Resources

, ,

About James

James is a Senior New Media Developer at MMT Digital, and has BA(Hons) in Design for Interactive Media from the University of Gloucestershire. He loves designing and producing all sorts of website and Flash-related things, as well as prattling on about technologies.Day-to-day he works with Flash, Dreamweaver, Director, Microsoft Office Sharepoint Server 2007 (MOSS) and in his spare time he mucks about in Flex and Wordpress.Follow James on Twitter.

24 Responses to “Creating Outlook Calendar events through hyperlinks”

  1. Nathan McCance 29th August, 2008 at 11:23 pm # Reply

    You may want to check your example “icalendar.ics” file. It won’t open in Apple’s iCal.

  2. blackock 6th October, 2008 at 11:42 pm # Reply

    Great stuff… how would you add other invitees automatically?

  3. James 7th October, 2008 at 9:21 am # Reply

    So far as I can tell from the spec, you can add people with the ATTENDEE element, in which you can put a list of all the people (and email addresses) that you want to attend.

    e.g.

    ATTENDEE;DELEGATED-FROM=”MAILTO:jsmith@host.com”:MAILTO:jdoe@host.com
    ATTENDEE;DELEGATED-TO=”MAILTO:jdoe@host.com”,”MAILTO:jqpublic@host.com”:MAILTO:jsmith@host.com
    ATTENDEE;MEMBER=”MAILTO:ietf-calsch@imc.org”:MAILTO:jsmith@host.com

    Obviously there’s no way for a simple text-based file to know who’s attending dynamically, but you can specify some initial persons – or power the whole thing with a server side solution.

  4. Lesta G 6th November, 2008 at 2:11 am # Reply

    Does not work in outlook 2003

    errors with

    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

  5. Dave Ramsey 14th May, 2009 at 9:21 pm # Reply

    If you want to take full advantage of the features offered via an .ics file, create the event while in Outlook and then save the event as an .ics file. That way you can include the a list of attendees and any other feature available via an Outlook event. Makes a “No Brainer” of the process of creating an .ics file.

  6. varumr 5th June, 2009 at 5:43 pm # Reply

    Hey Lesta G,

    Did you fian a fix to to problem you stated? I am having same problem. ANy help will be greatly appriciated.

    Thanks

  7. Jay 26th August, 2009 at 5:35 pm # Reply

    Lesta and varumr -

    I realize this is a little after the fact, but to get this to work with 2003, just add the line

    METHOD:PUBLISH

    to the VCALENDAR definition section.

  8. Graeme 4th September, 2009 at 2:31 pm # Reply

    When clicking on the .ics link above, Mozilla prompts me to open the file with my mail client or save it (as expected).

    However, I have created a similar .ics file and uploaded it to my web server, but when pasting the URL into the browser, all I see are the plain text details of the .ics file.

    Any ideas why?

  9. James 4th September, 2009 at 2:37 pm # Reply

    Graeme – That’s all about MIME-types on your server.

    Server delivered files rely less on file extensions and more on MIME-Types. Make sure your server is set to deliver files with an extension of .ics with the MIME-type “text/calendar” and that should fix it.

    (More info and references are in the article)

  10. Andrew 24th September, 2009 at 5:13 pm # Reply

    I have saved a number of .ics files on my local machine (desktop), when I open one of the files, change some details, and click save. None of the information get’s saved. When the file is opened it still shows the original meeting info from when the file was created. How can I save changes to .ics files saved locally with the intention of attaching links to them for a website for people to download?

  11. James 24th September, 2009 at 9:44 pm # Reply

    Andrew – my only guess is that when you’re editing the files in Outlook (or whatever client you’re using) it’s making a copy of the file and editing that.

    Without using the same editor to ‘export’ the file again I guess you won’t be able to see the changes.

    Or, I suppose you’d need a custom solution to not write the copied files out over the top of the original.

  12. event calendar 14th April, 2010 at 3:50 pm # Reply

    Thanks Jay I had this same issue. clever diaries downloading again properly.

  13. James 28th April, 2010 at 10:27 am # Reply

    this is great, very useful resource, may I ask is there a way the calendar event can automatically be saved? I really would like to create a diary entry and have it populate a users diary without the event popping up and requiring the user to “save & close”

    Many thanks, James

  14. James 28th April, 2010 at 3:13 pm # Reply

    James – Being able to auto-save the calendar event is something that is down to individual machines and applications, so there isn’t a way to avoid the “Save & Close’ requirement of applications like Outlook.

  15. david 7th July, 2010 at 4:27 pm # Reply

    I want to let the user have his info (meetings etc.) as an ics file. How do I store the file in the DB? create the file on each clients request? thanks (we use j2ee)

  16. James 7th July, 2010 at 11:32 pm # Reply

    @david – Depends on your setup, but you could either store the contents of the file (it’s only plain text, after all) in the database, or generate the file from multiple fields in the database.

    You could either generate downloadable icalendar files whenever the user requests them, and return those files, or you could even try doing it without generating a physical file, and just have a page request return the contents of the icalendar file, with the correct MIME-TYPE, and see how well that works. MIME-TYPEs are just as important (if not more) where server side stuff is concerned!

  17. JohnM 8th December, 2010 at 6:56 pm # Reply

    I’m running Win XP Pro SP3, and I checked under: File Explorer/Tools/Folder Options/File Types, but I cannot see how/where to set the MIME-type to “text/calendar” for .ICS files.

  18. James 8th December, 2010 at 8:46 pm # Reply

    Setting the MIME-type has to be done on the server that is offering the file as a download – it doesn’t work if you’re just doing it on your local machine.

    I think you’d have to set up the MIME-type in IIS, rather than your Explorer/File Types dialog, anyway.

  19. Carlos 22nd February, 2011 at 4:21 pm # Reply

    Once the event is built, as in the example, how should be submitted to the Exchange server, over email?, over HTTP? Stored into a staging server for Exchenge to pick it up?

  20. Maureen 15th June, 2011 at 7:07 pm # Reply

    I can embed the .ics file in the email and have them accept. When I tried to update the invite, the invitees received and accepted but then the original invite fell off my calendar. Any ideas why??

  21. Holden 19th July, 2011 at 10:46 pm # Reply

    Hi James,

    Good page of useful information. I would like to know if you’re using vcalendar or icalendar specifications? Also, how would you handle frequency or reoccurring events?

    Also are you following RFC5546 or 5545 for the standards? Do you find that oulook sticks to the standards outlined in the RFC’s? Thanks again!

  22. James 20th July, 2011 at 8:26 am # Reply

    @Holden – I’m afraid I’m not much of an expert on the exact formats, but iCalendar is supposedly based on the earlier vCalendar format.

    I haven’t had any trouble using either of the specifications in any Calendar clients – generally they handle everything you throw at them, so either RFC is good.

  23. Steve D 18th August, 2011 at 3:34 am # Reply

    Jay,
    You say to add
    “METHOD:PUBLISH
    to the VCALENDAR definition section.”

    Where exactly is that? I can’t get it to work.

    TIA, Steve

  24. Daniel Foster 12th January, 2012 at 8:00 pm # Reply

    This site works great for creating the iCalendar file and if you link to it on their server, the MIME type is already set:
    http://www.pratie.com/lab/icalendar/

Leave a Reply

Note: This post is over 3 years old. You may want to check later in this blog to see if there is new information relevant to your comment.