Psyked *
it’s easy once you know how.Creating Outlook Calendar events through hyperlinks
Posted by James - 07/08/08 at 11:08:02 pmYou 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.



You may want to check your example “icalendar.ics” file. It won’t open in Apple’s iCal.
Comment by Nathan McCance — 29 August 2008 #
Great stuff… how would you add other invitees automatically?
Comment by blackock — 6 October 2008 #
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.
Comment by James — 7 October 2008 #
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
Comment by Lesta G — 6 November 2008 #
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.
Comment by Dave Ramsey — 14 May 2009 #
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
Comment by varumr — 5 June 2009 #
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.
Comment by Jay — 26 August 2009 #
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?
Comment by Graeme — 4 September 2009 #
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)
Comment by James — 4 September 2009 #
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?
Comment by Andrew — 24 September 2009 #
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.
Comment by James — 24 September 2009 #
Thanks Jay I had this same issue. clever diaries downloading again properly.
Comment by event calendar — 14 April 2010 #
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
Comment by James — 28 April 2010 #
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.
Comment by James — 28 April 2010 #
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)
Comment by david — 7 July 2010 #
@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!
Comment by James — 7 July 2010 #