Making a link that will save an appointment in MS Outlook’s calendar

OK, so the link is an iCalendar file, but until I started looking for, I had no idea what it was called.

The Problem

In a nut shell, for a while now I’ve known about the existence of Google’s Save Event.  Which is great if you have a Google account and you’re signed in and you don’t have separate work and personal accounts.

At school, we use Outlook for EVERYTHING.   Quite possibly a bit too much.   I do hear: “I haven’t had a chance to read your email” as an excuse quite a bit.

What I wanted was the ability to generate a link, which when clicked on would add an appointment to my calendar as opposed to manually going to calendar, creating a new event, setting the time and date correctly, inviting others to the meeting, adding a room…  I’m boring myself.

The Solution

I eventually found a solution on Stackoverflow’s fourm

<?php

$ical = “BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//hacksw/handcal//NONSGML v1.0//EN
BEGIN:VEVENT
UID:” . md5(uniqid(mt_rand(), true)) . “@yourhost.test
DTSTAMP:” . gmdate(‘Ymd’).’T’. gmdate(‘His’) . “Z
DTSTART:20130715T100000Z
DTEND:20130715T110000Z
SUMMARY:Bastille Day Party
END:VEVENT
END:VCALENDAR”;

//set correct content-type-header
header(‘Content-type: text/calendar; charset=utf-8′);
header(‘Content-Disposition: inline; filename=calendar.ics’);
echo $ical;
exit;

?>

Which solves the problem quite nicely.  You need to put this in a PHP page, so you need a server which lets run PHP*.  This page also auto-closes once completed, so you need to link to this page from another.  When you run it the page closes itself.

The example above creates a .ics file which when run, opens up an appointment in MS Outlook for 15th July 2013 from 10 am until 11am and names the event Bastille Day party.  Wow, that will be some party!

I’ve tinkered a bit with the original, to make it easier to adapt.  My Comments are in green, things you can set are in red:

<?php

// If you point to this page from another page, you can add variables to the link: eg:

// calendar.php?startdate=201307015&apptTime=100000&location=My Office

// Start date format needs to be YYYYMMDD

$startdate=$_GET['startdate'];

// Appointment time format needs to be HHMMSS

$apptTime=$_GET['apptTime'];

// Location can be pretty much anything

$location=$_GET['location'];

$ical = “BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//hacksw/handcal//NONSGML v1.0//EN
BEGIN:VEVENT
UID:” . md5(uniqid(mt_rand(), true)) . “@yourhost.test
DTSTAMP:” . gmdate(‘Ymd’).’T’. gmdate(‘His’) . “Z
DTSTART:”.$startdate.”T”.$apptTime.”Z
DTEND:”.$startdate.”T”.$endTime.”Z
LOCATION:$location
SUMMARY;LANGUAGE=en-gb:$details
END:VEVENT
END:VCALENDAR”;
//set correct content-type-header
header(‘Content-type: text/calendar; charset=utf-8′);
header(‘Content-Disposition: inline; filename=IrisAppt.ics’);
echo $ical;
exit;

?>

You can also add ATTENDEES so that it can auto-generate a meeting.  This is a little trickier to work out.  In the end, I created an iCal file from Outlook and opened it in NotePad++.  Each attendee needs their own line and goes just below the LOCATION line:

ATTENDEE;CN=SomeBody;RSVP=TRUE:mailto:SomeBody@youremail.co.uk

And that’s it.   All you have to do is link to a page containing this code and it should do the rest.

Bonus for Iris Connect users/admins

One of my main reasons for wanting to make an automated appointment system is because I, along with two colleagues administrate Iris Connect in the school.  We need to know when the observations are happening and where.  The easiest way for us to do this if I get everyone to invite me to observe them.  I then put the observation in my diary, invite the other two in case I’m not in the office.  When I get the reminder I set the camera up and set the recording going.  It works really well.  But I get fed up making the appointments.

The beauty of the Iris Connect system is that it sends out an automated email.  It’s always the same format.  So I built a form which means I can copy and paste the text of the email, click submit and up pops an appointment.   I had a slow morning. :)

If you would like to make use of this little bonus, you can find the files here

I’ve spoken to the guys at Iris Connect about this already and apparently this level of functionality is in their roadmap.  But why wait.


* I’m going to do another post very soon# which provides a solution for those of you who don’t have access to a server.

# I promise

About these ads

One Response to Making a link that will save an appointment in MS Outlook’s calendar

  1. […] my last post, I talked about using PHP and if you didn’t have access to a server that allowed PHP to run, […]

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

Follow

Get every new post delivered to your Inbox.

Join 299 other followers

%d bloggers like this: