To delete an exchange item, use the ColdFusion Exchange tag with the action attribute of delete and specify the item UID. Deleting the exchange item deletes all attachements
To delete only the attachments to an exchange item, use the ColdFusion Exchange tag with the action attribute of deleteAttachments and specify the item UID,
This example deletes all meeting requests in the Inbox for meetings that have passed, but does not delete any requests in folders in the Inbox. To delete requests in the Inbox, you must use a separate cfexchangemail tag for each folder. For information on accessing and using multiple folders, see Getting and using folder names.
<cfexchangeconnection action="open" username ="#user#" password="#password#" server="#exchangeServerIP#" connection="conn1"> <!--- Get all meeting notifications from the Inbox. ---> <cfexchangemail action="get" name="requests" connection="conn1"> <cfexchangefilter name="MessageType" value="Meeting"> </cfexchangemail> <!--- Get the meeting request data and put it in an array. ---> <cfset i=1> <cfset meetingData=ArrayNew(1)> <cfloop query="requests"> <cfexchangemail action="getmeetinginfo" connection="conn1" name="meeting" meetinguid="#MeetingUID#" mailUID="#UID#"> <cfset meetingData[i]=meeting> <cfset i=i+1> </cfloop> <!--- Loop through the request data array and delete any outdated meeting messages from the Inbox. ---> <cfloop index="i" from="1" to="#ArrayLen(meetingData)#" > <cfif meetingData[i].StartTime LTE now()> <cfexchangemail action="delete" connection="conn1" UID="#meetingData[i].UID#"> </cfif> </cfloop> <cfexchangeconnection action="close" connection="conn1">
For another example that deletes all mail from a known spam address, see Using persistent connections.