Author Topic: Add to Outlook Calendar  (Read 1390 times)

0 Members and 1 Guest are viewing this topic.

Offline smc

  • Full Member
  • ***
  • Posts: 45
    • EternityWhere.com
Add to Outlook Calendar
« on: June 01, 2011, 06:34:33 AM »
I have an announcements section on my EZ-powered website (www.colerainefpc.org) and thought that it would be nice to have a button with "Add to Outlook Calendar" on each announcement page for the event described.  Of course I wanted to do this with the scripts interfacing with my original anouncements database.

I needed to be able to download an *.ics file that would interface with Outlook.  Inspiration came from this post http://www.ezscriptingforums.com/index.php?topic=393.0

Here is what I did.  I modified a copy of the read/search script as follows.

I changed the line:

print "Content-type: text/html\n\n";

to

print "Content-Type:application/x-download\n";
print "Content-Disposition: attachment; filename=AddToCalendarFromColeraineFreePresbyterianChurch.ics\n\n";


Sorry, that generates quite a long filename for the *.ics file but it works ok!

I then downloaded an *.ics file from another site (or you could export one from Outlook) and realised that this could be used as a template file.

Here is what the template file looks like:

Quote
BEGIN:VCALENDAR<template>
VERSION:2.0
METHOD:PUBLISH
BEGIN:VEVENT
UID:0
DTSTAMP:20110601T080000
DTSTART;VALUE=DATE:[[dtstart]]
DTEND;VALUE=DATE:[[dtend]]
SUMMARY:[[meeting]] 
LOCATION: Coleraine Free Presbyterian Church  http://www.ColeraineFPC.org
DESCRIPTION:[[sitewideText]]  \n  [[primary_activity]]  [[speaker_title]] [[speaker_firstname]] [[speaker_surname]]  [[speaker_location]]  \n 
END:VEVENT
END:VCALENDAR

</template>

The tags above are just pulling in information from my database. 

DTSTART and DTEND need to be in a specific format - see below in an executed example *.ics file.  I inserted new fields to do this.

Quote
BEGIN:VCALENDAR
VERSION:2.0
METHOD:PUBLISH
BEGIN:VEVENT
UID:0
DTSTAMP:20110601T080000
DTSTART;VALUE=DATE:20110612T204500Z
DTEND;VALUE=DATE:20110612T220000Z
SUMMARY:After Church Youth Rally 
LOCATION: Coleraine Free Presbyterian Church  http://www.ColeraineFPC.org
DESCRIPTION:Our next After Church Youth Rally, the last in the current series, is on Sunday 12th June 2011  \n  Special Speaker:  Mr. Lavelle McIlrath  (Tandragee)  \n 
END:VEVENT
END:VCALENDAR


Make sure there are no spaces after BEGIN:VCALENDAR or it will not work in Outlook 2007.  I have tested it in Outlook 2003 and Outlook 2007 and it works fine.

To see an example in action visit:  http://www.colerainefpc.org/cgi-bin/announcements/announcements.cgi?ID=1224&template=announce and then click on the link to the left of the announcement information.  This will download the *.ics file which you can inspect for yourself and then open it with Outlook to load the data into your calendar.

Hope you find it useful and many thanks to ADalby for the original post that got me thinking!