Emailing Outlook Appointments

Posted on 2006-05-23
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
    LVL 7

    Expert Comment

    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

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

    Accepted Solution

    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 (
     * @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">
    LVL 4

    Author Comment

    Thanks bhinshawnc1! That did the trick!

    Featured Post

    PRTG Network Monitor: Intuitive Network Monitoring

    Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

    Join & Write a Comment

    Suggested Solutions

    In our day to day coding, how many times have we come across a necessity to check whether a URL is a broken link or not? For those of you that answered countless and are using ColdFusion like myself, then this article is for you.  It will show yo…
    Article by: kevp75
    Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
    The purpose of this video is to demonstrate how to reset a WordPress password if you are locked out and cannot reset the password. A typical use would be if you cannot access the email to which WordPress would send the password recovery email to…
    The purpose of this video is to demonstrate how to prevent comment spam on a WordPress Website. This will be demonstrated using a Windows 8 PC. Plugin Akismet will be used. Go to your WordPress login page. This will look like the following: myw…

    728 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

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now