0

I'm looking for ColdFusion code to add "Add to Calendar" links to our events page similar to the links on EventBrite and Meetup.com. They have links for adding their events to your Outlook, Google and iCal calendars. If there is code in other languages with similar functionality I can work with that.

jim collins
  • 417
  • 1
  • 8
  • 17
  • OK so to prevent confusion by others, the links on Meetup.com to add to Outlook and add to iCal generate EXACTLY THE SAME iCal file. Sneaky weasels. So you only need iCal and Google. – jim collins Oct 20 '14 at 16:09
  • The other questions answers don't address Google Calendar. – jim collins Oct 20 '14 at 16:12

2 Answers2

3

Here's an example of providing an .ics file for a specific calendar event:

<cfset ICSContent = "">
<cfset ICSContent = ICSContent & "BEGIN:VCALENDAR#chr(13)##chr(10)#">
<cfset ICSContent = ICSContent & "VERSION:2.0#chr(13)##chr(10)#">
<cfset ICSContent = ICSContent & "CALSCALE:GREGORIAN#chr(13)##chr(10)#">
<cfset ICSContent = ICSContent & "PRODID:Coldfusion8#chr(13)##chr(10)#">
<cfset ICSContent = ICSContent & "BEGIN:VEVENT#chr(13)##chr(10)#">
<cfset ICSContent = ICSContent & "UID:#eventItem.getEvent_id()#@extension.unh.edu#chr(13)##chr(10)#">
<cfset ICSContent = ICSContent & "SUMMARY:#eventItem.getTitle()##chr(13)##chr(10)#">
<cfset ICSContent = ICSContent & "DESCRIPTION:http://extension.unh.edu/events/index.cfm?e=app.event&event_id=#eventItem.getEvent_id()##chr(13)##chr(10)#">
<cfset ICSContent = ICSContent & "DTSTART:#DateFormat(DateAdd('h',timeInfo.utcHourOffset,eventItem.getGmt_start()),"yyyymmdd")#T#TimeFormat(DateAdd('h',timeInfo.utcHourOffset,eventItem.getGmt_start()),"HHmmss")#Z#chr(13)##chr(10)#">
<cfset ICSContent = ICSContent & "DTEND:#DateFormat(DateAdd('h',timeInfo.utcHourOffset,eventItem.getGmt_end()),"yyyymmdd")#T#TimeFormat(DateAdd('h',timeInfo.utcHourOffset,eventItem.getGmt_end()),"HHmmss")#Z#chr(13)##chr(10)#">
<cfset ICSContent = ICSContent & "DTSTAMP:#DateFormat(DateAdd('h',timeInfo.utcHourOffset,Now()),"yyyymmdd")#T#TimeFormat(DateAdd('h',timeInfo.utcHourOffset,Now()),"HHmmss")#Z#chr(13)##chr(10)#">
<cfset ICSContent = ICSContent & "END:VEVENT#chr(13)##chr(10)#">
<cfset ICSContent = ICSContent & "END:VCALENDAR">
<cfheader name="Content-Type" value="text/calendar">
<cfheader name="Content-Disposition" value="attachment; filename=UNHCEevent#DateFormat(eventItem.getGmt_start(),"yyyymmdd")#.ics">
<cfoutput>#ICSContent#</cfoutput>
Steve Judd
  • 218
  • 2
  • 6
1

I believe you may be talking about generating an ical string. This seems to be covered here: https://stackoverflow.com/a/2946423/52160

Community
  • 1
  • 1
Raymond Camden
  • 10,661
  • 3
  • 34
  • 68