ColdFusion 9.0 Resources |
cfexchangemailDescriptionGets mail messages and attachments, deletes messages, and sets properties for messages on a Microsoft Exchange server. Syntaxdelete <cfexchangemail required action = "delete" uid = "message UID,message UID,..." optional connection = "connection ID" folder = "Exchange folder path"> deleteAttachments <cfexchangemail required action = "deleteAttachments" uid = "message UID" optional connection = "connection ID"> folder = "Exchange folder path"> get <cfexchangemail required action = "get" name = "query identifier" optional connection = "connection ID" folder = "Exchange folder path"> <cfexchangefilter name = "filter type" value = "filter value"> <cfexchangefilter name = "filter type" value = "filter value"> ... </cfexchangemail> getAttachments <cfexchangemail required action = "getAttachments" name = "query identifier" uid = "message UID" optional attachmentPath = "directory path" connection = "connection ID" folder = "Exchange folder path" generateUniqueFilenames = "no|yes"> getMeetingInfo <cfexchangemail required action = "getMeetingInfo" meetingUID = "meeting UID" name = "query identifier" optional connection = "connection ID" mailUID = "message UID"> move <cfexchangemail required action = "move" destinationFolder = "Exchange folder path" optional connection = "connection ID" folder = "Exchange folder path"> <cfexchangefilter name = "filter type" value = "filter value"> <cfexchangefilter name = "filter type" value = "filter value"> ... </cfexchangemail> set <cfexchangemail required action = "set" message = "#structure with values to set#"> uid = "message UID"> optional connection = "connection ID" folder = "Exchange folder path"> Note: If you omit the connection attribute,
create a temporary connection by specifying cfexchangeconnection tag
attributes in the cfexchangemail tag. In this case,
ColdFusion closes the connection when the tag completes. For details,
see the cfexchangeconnection tag open action.
Note: You can specify this tag’s attributes in an attributeCollection attribute
whose value is a structure. Specify the structure name in the attributeCollection attribute
and use the tag’s attribute names as structure keys.
See alsocfexchangecalendar,cfexchangeconnection, cfexchangecontact, cfexchangefilter, cfexchangetask, Interacting with Microsoft Exchange Servers in the Developing ColdFusion Applications AttributesNote: If an attribute, such as folder or destinationFolder takes
a folder path, and the folder name contains forward slashes (/),
specify the folder name by using the _xF8FF_ escape character to
prevent exchange from interpreting the character as a path delimiter.
UsageThe cfexchangemail tag performs mail actions on an Exchange server that you cannot do by using the cfmail tag. (You must use the cfmail tag to send, forward, and reply to mail messages.) Use the cfexchangemail tag to perform the following actions:
To use this tag, you must have a connection to an Exchange server. If you are using multiple tags that interact with the exchange server, such as if you are creating several contact records, use the cfexchangeconnection tag to create a persistent connection. You then specify the connection identifier in each cfexchangemail tag, or any other ColdFusion Exchange tag, if you are also accessing tasks, contacts, or connections. Doing this saves the overhead of creating and closing the connection for each tag. Alternatively, you can create a temporary connection that lasts only for the time that ColdFusion processes the single cfexchangemail tag. To do this, you specify the connection attributes directly in the cfexchangemail tag. For details on the connection attributes, see the cfexchangeconnection tag. The delete actionThe delete action permanently deletes a message from the server, and is equivalent to the Outlook Shift-Delete keystroke action. Use the move action to move a message to the Deleted Items folder, which is equivalent to the Outlook Delete keystroke action. When you specify the delete action you must specify a uid attribute with a comma-delimited list of one or more Exchange UIDs that identify the tasks that you want to delete. You can use the get action, with an appropriate filter expression, to determine the UID values to specify. If all UIDs that you specify are invalid, the cfexchangemail tag generates an error. If at least one UID is valid, the tag ignores any invalid UIDs and deletes the items specified by the valid UID. The get actionWhen you specify the get action, you use child cfexchangefilter tags to specify the messages to get. For detailed information, see cfexchangefilter. When the tag completes processing, the query object specified by the name attribute contains one record for each matching message that was found. Each record has the following columns:
Note: An invitation sender can
get a meeting request message only if the sender is on the attendee
list.
The getAttachments actionWhen you use the getAttachments action, specify a single UID and a name attribute. The cfexchangecontact tag populates a query object specified by the name attribute with one record for each attachment. Each record has the following information about the mail attachment specified by the UID:
The tag places the attachments in the directory specified by the attachmentPath attribute. If you omit the attachmentPath attribute, ColdFusion does not get any attachments; it gets the information about the attachments. This lets you determine the attachments without incurring the overhead of getting the attachment files. If a message has multiple attachments with the same name, the attachment information structure always lists the attachments with their original, duplicate, names, even if you specify generateUniqueFilenames="yes". The generateUniqueFilenames attribute only affects the names of the files on disk. Use the following syntax to specify an in-memory attachmentPath directory. In-memory files are not written to disk and speed processing of transient data. attachmentpath = "ram:///path" The path can include multiple directories, for example ram:///petStore/orders/messageAttachments. Create all directories in the path before you specify the file. For more information on using in-memory files, see Optimizing transient files in the Developing ColdFusion Applications. The getAttachments action works only if authentication for EWS (Exchange Web Services) is set to basic in the server setup of Exchange. IWA (Integrated Windows Authentication) is not supported. The getMeetingInfo actionYou use the getMeetingInfo action to get meeting-specific information, such as the meeting start and end times, location, and so on, about a meeting for which you have received a notification message, such as an invitation request or cancellation notice. This information is not available directly in the notification message query object that is returned by the get action. Note: At the time of publication, the following information
does not completely reflect the behavior of the getMeetingInfo action.
For updated information, see cfexchangemail in
the ColdFusion documentation available online in HTML on the Adobe
website.
When you specify the getMeetingInfo action, you specify a meetingUID attribute with the UID of the meeting. You get this UID value from the query record that is returned by the get action. You can optionally specify a messageUID attribute with the UID of the specific message that contains the notification; if you receive multiple messages about a single meeting, you can use this attribute to select a single notification message. When the tag completes processing, the query object specified by the name attribute contains one record for each matching message that was found. Each record has the following columns:
The move actionUse the move action to move one or more messages from one folder to another folder. You can use this action to move messages to the Deleted Items folder, which is equivalent to the Outlook Delete keystroke action. When you specify the move action you specify the destination folder, and optionally the folder containing the messages to move. (The default source folder is the Inbox). You use child cfexchangefilter tags to specify the messages to get. For detailed information, see cfexchangefilter. The set actionWhen you specify the set action, the structure specified by the message attribute contains key-value pairs that specify the message properties to set. The following table lists the key names and their valid values:
ExampleThe following example gets the attachments to all mail messages in the Inbox from docuser2 in the last week. It puts each message’s attachments in a directory with a unique name. It cannot use the UID as a filename because, for each message with attachments, the UID can contain the application reports of the UID, directory path, subject, date, and sender of the message, followed by a table that lists the message’s attachments. The table includes the attachment name, size, and MIME type. <!--- Index for message attachement directory ---> <cfset i=1> <!--- Dates for date range ---> <cfset rightNow = Now()> <cfset lastWeek = DateAdd("d","-7", rightNow)> <cfexchangeconnection action="open" username ="#user1#" password="#password1#" server="#exchangeServerIP#" connection="testconn1"> <cfexchangemail action="get" folder="Inbox " name="weeksMail" connection="testconn1"> <cfexchangefilter name="FromID" value="docuser2"> <cfexchangefilter name="TimeSent" from="#lastWeek#" to="#rightNow#"> </cfexchangemail> <cfloop query="weeksMail"> <cfif weeksmail.HasAttachment> <cfexchangemail action="getAttachments" connection="testconn1" folder="Inbox/MailTest" uid="#weeksmail.uid#" name="attachData" attachmentPath="C:\temp\cf_files\attachments\msg_#i#" generateUniqueFilenames="yes"> <cfoutput> Message ID #weeksmail.uid# attachments are in the directory C:\temp\cf_files\attachments\Msg_#i#<br /> <br /> Message information:<br /> Subject: #weeksmail.Subject#<br /> Sent: #dateFormat(weeksmail.TimeSent)#<br /> From: #weeksmail.FromID#<br /> <br /> Attachments<br /> <cftable query="attachData" colheaders="yes"> <cfcol header="File Name" text="#attachmentFilename#"> <cfcol header="Size" text="#size#"> <cfcol header="MIME type" text="#mimeType#"> </cftable> </cfoutput> <cfset i++> </cfif> </cfloop> <cfexchangeconnection action="close" connection="testconn1"> |