You can modify any elements of calendar, contact, and task items that you can set in ColdFusion. For mail message, you can change the Importance, Sensitivity, and IsRead flags, and you can move the mail messages between folders.

Note: If an item has attachments and you specify attachments when you modify the item, the new attachments are added to the previous attachments; they do not replace them. Use the deleteAttachments action to remove any obsolete or changed attachments.

Modifying calendar, contact, and task items

You can modify calendar, contact, and task items by using the cfexchangecalendar, cfexchangecontact, or cfexchangetask tag with an action attribute value of modify. You specify a contact, event, or task attribute with a structure that contains the item properties that you want to change, and their new values. You do not have to specify the values for properties that you are not changing. To change the end time of a calendar task, for example, you specify only an EndTime field in the event attribute structure. 
The following example lets you create, and then modify a calendar event. When you first submit the form, ColdFusion creates the calendar event and redisplays the form with the data you entered. Accept the event before you modify the form and resubmit it. When you submit the form a second time, ColdFusion sends the modification information. For information about accepting events, see Working with meetings and appointments.
The following example resends all the event data (to limit the example length), but you could change the example so that it only sends modified data. This example also omits recurrence information to keep the code relatively simple:

<!--- The EventID field is a hidden field managed by this application. --->
<cfparam name="form.eventID" default="0">

<!--- If the form was submitted, populate an event structure from it. --->
<cfif isDefined("Form.Submit")>
if (IsDefined("Form.allDay")) {
sEvent.StartTime=createDateTime(Year(, Month(,
Day(, 8, 0, 0);
else {
sEvent.StartTime=createDateTime(Year(, Month(,
Day(, Hour(Form.startTime), Minute(Form.startTime), 0);
sEvent.EndTime=createDateTime(Year(, Month(,
Day(, Hour(Form.endTime), Minute(Form.endTime), 0);
if (Form.reminder NEQ "") {
else {

<!--- If the form is being submitted for the first time,
create an event. --->
<cfif form.eventID EQ 0>
<!--- Create the event in Exchange --->
<cfexchangecalendar action="create"
username ="#user1#"
<!--- Display the new event UID and set form.eventID to it. --->
<cfif isDefined("theUID")>
<cfoutput>Event Added. UID is #theUID#</cfoutput>
<cfset Form.eventID = theUID >

<!--- The form is being resubmitted with new data; update the event. --->
<cfexchangecalendar action="modify"
username ="#user1#"
<cfoutput>Event ID #Form.eventID# Updated.</cfoutput>


<!--- A self-submitting form for the event information --->
<cfform format="xml" preservedata="true" style="width:500" height="600">
<cfinput type="text" label="Subject" name="subject" style="width:435">
<br />
<cfinput type="checkbox" label="All Day Event" name="allDay">
<cfinput type="datefield" label="Date" name="date" validate="date"
<cfinput type="text" label="Start Time" name="startTime" validate="time"
<cfinput type="text" label="End Time" name="endTime" validate="time"
style="width:100"><br />
<cfinput type="text" label="Location" name="location"
style="width:435"><br />
<cfinput type="text" label="Required Attendees" name="requiredAttendees"
style="width:435"><br />
<cfinput type="text" label="Optional Attendees" name="optionalAttendees"
style="width:435"><br />
<cfinput type="text" label="Resources" name="resources"
style="width:435"><br />
<cfinput type="text" label="Reminder (minutes)" validate="integer"
name="reminder" style="width:200">
<cfselect name="importance" label="Importance" style="width:100">
<option value="normal">Normal</option>
<option value="high">High</option>
<option value="low">Low</option>
<cfselect name="sensitivity" label="Sensitivity" style="width:100">
<option value="normal">Normal</option>
<option value="company-confidential">Confidential</option>
<option value="personal">Personal</option>
<option value="private">Private</option>
<cfinput type="textarea" label="Message" name="message" style="width:435;
<cfinput type="hidden" name="eventID" value="#Form.EventID#">
<cfinput type="Submit" name="submit" value="Submit" >

Setting mail attributes

To set a mail message's Importance, Sensitivity, or IsRead flag, use the cfexchangemail tag with an action attribute value of set. Specify only the flags that you are changing in the message attribute.
The following example snippet implements a catch-up operation by changing the IsRead flag to true on all mail messages that are directly in the Inbox and are more than two weeks old. The example does not change the flags on any messages in folders in the Inbox; to do so, use a separate cfexchangemail tag for each folder. For information on accessing and using multiple folders, see Getting and using folder names in Getting Exchange items and attachments.

<cfset changeValues.IsRead="true">

<!--- Open the connection. --->
username ="#user1#"

<!--- Get the mail in the Inbox that is at least two weeks old. --->
<cfexchangemail action="get" name="oldMail" connection="conn1">
<cfexchangefilter name="timeSent" from="01/01/2000"
to="#DateAdd("d","-14", Now())#">

<!--- Loop through the resulting oldMail query and set the IsRead indicator
to true. --->
<cfloop query="oldMail">
<cfexchangemail action="set"

<!--- Close the connection. --->

Moving mail between folders

To move a one or more mail messages from one folder to another, use the cfexchangemail tag move action, as shown in the following code snippet, which moves all messages with the subject "Rams and Ewes" from the Unread folder in the Inbox to the Sheep folder in the inbox.

<cfexchangemail action="move" connection="con1" folder="Inbox/Unread"
<cfexchangefilter name="subject" value="Rams and Ewes">


This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License  Twitter™ and Facebook posts are not covered under the terms of Creative Commons.

Legal Notices   |   Online Privacy Policy