Emailing Outlook Appointments

Posted on 2006-05-23
Medium Priority
Last Modified: 2013-12-24
Is there a way to dynamically create an outlook appointment with ColdFusion? I'd like to send an email where the recipient can accept an appointment with the proposed time added to their calendar.
Question by:CodeParadise

Expert Comment

ID: 16756058
There are some COM libraries available for Outlook/Exchange called CDO (Collaboration Data Objects) that enable you do do this. The following links should help:



Hope this helps

LVL 13

Expert Comment

ID: 16760971
You might be able to create an ICS file too, pretty simple syntax, and would help if you couldn't use COM.

Accepted Solution

bhinshawnc1 earned 2000 total points
ID: 16809707
Here's a ICS example:

<cfquery name="qry_training_for_cal" datasource="#dbname#" username="#dbuser#" password="#dbpw#">
SELECT     dbo.Training_Events.Event_ID, dbo.Training_Events.Event_Title, dbo.Training_Events.Location, dbo.Training_Events.Event_Start_Date,   dbo.Training_Events.Event_End_Date, dbo.Training_Events.Event_Start_Time, dbo.Training_Events.Event_End_Time, dbo.Training_Events.description,  DATEADD(minute, DATEDIFF(minute, GETUTCDATE(), getdate()), Event_Start_Time) AS GMT_Start_time,  DATEADD(minute, DATEDIFF(minute, GETUTCDATE(), getdate()), Event_End_Time) AS GMT_End_time
FROM         dbo.Training_Events
WHERE     dbo.Training_Events.Event_ID = '#cfgridkey#'

<!--- now send them a calendar invite --->

<!--- figure out time zone for server --->
<cfset mytime = GetTimeZoneInfo()>

<!---difference in server time to UTC in hours #mytime.utcHourOffset# <br />
check for Daylight savings on server DST on #mytime.isDSTon# <br />--->
<cfset servertimeoffset = #mytime.utcHourOffset# >


stEvent = StructNew();

vCalOutput = vCal(stEvent);

 * Produces output used by the vCalendar standard for PIM's (such as Outlook).
 * There are other tags available such as (CF_AdvancedEmail) that will support multi-part mime encoding where the text of the attachment can be imbeded right into the email
 * @param stEvent        Structure containg the key/value pairs comprising the vCalendar data.  Keys are shown below:
 * @param stEvent.description        Description for the event.
 * @param stEvent.subject        Subject of the event.
 * @param stEvent.location        Location for the event.
 * @param stEvent.startTime        Event's start time in GMT.
 * @param stEvent.endTime        Event's end time in GMT.
 * @param stEvent.priority        Numeric priority for the event (1,2,3).
 * @return Returns a string.
 * @author Chris Wigginton (cwigginton@macromedia.com)
 * @version 1.1, April 10, 2002
function vCal(stEvent)

      var description = "";
      var vCal = "";
      var CRLF=chr(13)&chr(10);
      if (NOT IsDefined("stEvent.startTime"))
            //stEvent.startTime = DateConvert('local2Utc', Now());
            //stEvent.startTime = DateConvert('local2utc',#qry_training_for_cal.GMT_Start_Time#);
            stEvent.startTime = DateConvert('local2utc',#neweventstart#);
      if (NOT IsDefined("stEvent.endTime"))
            //stEvent.endTime = DateConvert('local2Utc', Now());
            //stEvent.endTime = "#qry_training_for_cal.GMT_End_Time#";
            //stEvent.endTime = DateConvert('local2utc',#qry_training_for_cal.GMT_End_Time#);
            stEvent.endTime = DateConvert('local2utc',#neweventend#);
      if (NOT IsDefined("stEvent.location"))
            stEvent.location = "#qry_training_for_cal.location#";
      if (NOT IsDefined("stEvent.subject"))
            stEvent.subject = "AESE Training: #qry_training_for_cal.Event_Title#";
      if (NOT IsDefined("stEvent.description"))
            stEvent.description = "#qry_training_for_cal.description#";
      if (NOT IsDefined("stEvent.priority"))
            stEvent.priority = "1";
            stEvent.startDate = "#qry_training_for_cal.Event_Start_Date#";
            stEvent.endDate =  "#qry_training_for_cal.Event_End_Date#";

      vCal = "BEGIN:VCALENDAR" & CRLF;
      vCal = vCal & "PRODID:-//Microsoft Corporation//OutlookMIMEDIR//EN" & CRLF;
      vCal = vCal & "VERSION:1.0" & CRLF;
      vCal = vCal & "BEGIN:VEVENT" & CRLF;
      vCal = vCal & "DTSTART:" & DateFormat(stEvent.startDate,"yyyymmdd") & "T" & TimeFormat(stEvent.startTime, "HHmmss") & "Z" & CRLF;
                  //DateFormat(stEvent.startTime,"yyyymmdd") & "T" & 
//                  TimeFormat(stEvent.startTime, "HHmmss") & "Z" & CRLF;
      vCal = vCal & "DTEND:" & DateFormat(stEvent.endDate,"yyyymmdd") & "T" & TimeFormat(stEvent.endTime, "HHmmss") & "Z" & CRLF;
                  //      DateFormat(stEvent.endTime, "yyyymmdd") & "T" & 
//                  TimeFormat(stEvent.endTime, "HHmmss") & "Z" & CRLF;
      vCal = vCal & "LOCATION:" & stEvent.location & CRLF;
      vCal = vCal & "SUMMARY;ENCODING=QUOTED-PRINTABLE:" & stEvent.subject & CRLF;
      // Convert CF_CRLF (13_10) into =0D=0A with CR/LF and indent sequences
      description = REReplace(stEvent.description,"[#Chr(13)##Chr(10)#]", "=0D=0A=#Chr(13)##Chr(10)#     ", "ALL");
      vCal = vCal & description & CRLF;
      vCal = vCal & "PRIORITY:" & stEvent.priority & CRLF;
      vCal = vCal & "END:VEVENT" & CRLF;
      vCal = vCal & "END:VCALENDAR" & CRLF;      
      return vCal;

<!--- debug to see vcal info
#vCalOutput# --->
<!--- write the ics and then send it from  training mailbox, lock file to ensure sending right file, multiple requests processed fifo--->

<cflock name="#request.physicalroot#\event_registration.ics" timeout="10" type="exclusive">

<cf_sanfile action="write" file="#request.physicalroot#\event_registration.ics" output="#vcaloutput#">
      <cfmail to="x" from="y" subject="Training Registration: #qry_training.Event_Title#">
     <cfmailparam file="#request.physicalroot#\event_registration.ics">

Author Comment

ID: 16997903
Thanks bhinshawnc1! That did the trick!

Featured Post

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
Dramatic changes are revolutionizing how we build and use technology. Every company is automating, digitizing, and modernizing operations. We need a better, more connected way to work together as teams so we can harness the insights from our system…
The purpose of this video is to demonstrate how to connect a WordPress website to Google Analytics. This will be demonstrated using a Windows 8 PC Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php :…
The purpose of this video is to demonstrate how to integrate Mailchimp with WordPress, by placing a Mailchimp signup form on a WordPress Page or Post. This will be demonstrated using a Windows 8 PC. Mailchimp will be used. Log into your Mailchi…
Suggested Courses

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question