HOME | FERGUSON Digital Blog

Outlook 2007 vCal

ColdFusion Add comments

It's very easy to have ColdFusion send an email message to someone to tell them that they have an appointment. Turns out it's just as easy to have ColdFusion send out the actual Calendar appointment (in a corporate environment) directly into the Outlook Appointment Calendar.

To learn how the appointment is actually set, try making an appointment in Outlook (not Outlook Express) and save it as an ICS file. Then open the file with an ASCII editor of choice (notepad works just fine) and you will find all the parameters needed to slip into a CFMAILPART parameter. This example uses Outlook 2007 and will not work with POP3, only Exchange Servers.

The person receiving the email also receives an ICS file attachment which Outlook accepts as a valid calendar entry and makes the appointment. Now all you have to do is make them show up for the appointment!

<!---
#ATTRIBUTES.MailTo# = email address of recipient
#ATTRIBUTES.MailFrom# = email address of sender
#ATTRIBUTES.MailName# = name of recipient
#ATTRIBUTES.MailMessage# = email message
#ATTRIBUTES.MailAppoint# = brief description of appointment
#ATTRIBUTES.MailStart# = appointment start date (01/01/2010 12:00:00)
#ATTRIBUTES.MailStop# = appointment end date (02/02/2010 12:00:00)
--->


<cfset DTStartDate=DateFormat(DateConvert("local2UTC", ATTRIBUTES.MailStart), "yyyymmdd")>
<cfset DTStartTime=TimeFormat(DateConvert("local2UTC", ATTRIBUTES.MailStart), "HHMMSS")>

<cfset DTEndDate=DateFormat(DateConvert("local2UTC", ATTRIBUTES.MailStop), "yyyymmdd")>
<cfset DTEndTime=TimeFormat(DateConvert("local2UTC", ATTRIBUTES.MailStop), "HHMMSS")>

<cfmail to="#ATTRIBUTES.MailTo#" from="#ATTRIBUTES.MailFrom#" subject="Reminder (vCal)">
   <cfmailparam name="Disposition-Notification-To" value="#ATTRIBUTES.MailFrom#" />
   <cfmailparam name="content-class" value="urn:content-classes:calendarmessage" />
   <cfmailparam name="content-type" value="text" />
   <cfmailparam name="method" value="request" />
   <cfmailparam name="charset" value="utf-8" />
   <cfmailparam name="content-transfer-encoding" value="7bit" />
   <cfmailpart type="text">#ATTRIBUTES.MailMessage#</cfmailpart>
   <cfmailpart type="text/calendar">
<!--- Do NOT Indent This Part --->
BEGIN:VCALENDAR
PRODID:-//Microsoft Corporation//Outlook 12.0 MIMEDIR//EN
VERSION:2.0
METHOD:PUBLISH
BEGIN:VEVENT
DTSTART:#DTStartDate#T#DTStartTime#Z
DTEND:#DTEndDate#T#DTEndTime#Z
TRANSP:OPAQUE
SEQUENCE:0
UID:#CreateUUID()##DateFormat(Now(), "yyyymmdd")##TimeFormat(Now(), "hhmmss")#
DTSTAMP:#DTStartDate#T#DTStartTime#
DESCRIPTION:#ATTRIBUTES.MailName# on #ATTRIBUTES.MailStart# until #ATTRIBUTES.MailStop#
SUMMARY:#ATTRIBUTES.MailAppoint# Appointment
PRIORITY:5
X-MICROSOFT-CDO-IMPORTANCE:1
CLASS:PUBLIC
END:VEVENT
END:VCALENDAR
</cfmailpart>
</cfmail>

If you find this post useful please leave a comment and let me know how you used the information.

4 responses to “Outlook 2007 vCal”

  1. viki on Hi,
    I tried your code but got empty mails...never got the invite...
    Please let me know whats d problem with this code below:

    BEGIN:VCALENDAR
    PRODID:-//Microsoft Corporation//Outlook 11.0 MINMEDIR//EN
    VERSION:2.0
    METHOD:REQUEST
    BEGIN:VEVENT
    ORGANIZER:MAILTO:abi@EMPRESSSYSTEMS.COM
    DTSTART:201180609T121000Z
    DTEND:20110609T123000Z
    LOCATION:Reno
    TRANSP:OPAQUE
    SEQUENCE:0
    UID:109
    DTSTAMP:20110609T140000Z
    DESCRIPTION:D
    SUMMARY:S
    PRIORITY:5
    X-MICROSOFT-CDO-IMPORTANCE:1
    CLASS:PUBLIC
    END:VEVENT
    END:VCALENDAR
  2. Michael Ferguson on @Viki, looks like you've set the beginning of the calendar appointment to start in month 806 instead of month 06. There is an extra digit in the start date:

    201180609T121000Z
    20110609T121000Z

    Hope that helps.
  3. Abi on hi,

    I need to generate a calendar invite for multiple sessions..........For example, a meeting request exists for monday, tuesday and friday between 4 pm and 5 pm.............So is this possible, sending just one email instead of three emails for the multiple requests...Can u suggesst me the ics file format modifciations in this case.........
  4. Michael Ferguson on @Abi, unfortunately there is a limitation in Outlook that prevents multiple appointments from being saved to an ICS file. So you can only send one appointment per ICS.

    You can send multiple ICS files in a single email with instructions in the message for the recipient to open each appointment request.

Leave a Reply



© Copyright 1997-2024, All Rights Reserved Coldfusion and MS SQL2008
Powered by Mango Blog.   Design by FERGUSON Digital
o:Event name="beforeHtmlBodyEnd" />