Skip to main content
Legend
April 24, 2020
Answered

'Failure' Error When Getting Attachments with CFExchangeMail

  • April 24, 2020
  • 1 reply
  • 793 views

Anyone had any luck get email attachments using the CFEXCHANGEMAIL tags?

We are able to establish a connection to Office365 and can get the mail.  But, when a message indicates it has an attachment and we try to get it, the whole operation crashes with only the word: 'Failure'  displayed on the page.

 

In this particular case there are 3 messages.  Just one has an attachment.

 

We are using CF2018.

 

 

<!--- This works fine --->
<cfexchangeconnection action="open"
     username="ouremail@ourdomain.com"
     password="XXXXXXX"
     server="outlook.office365.com"
     protocol="https"
     serverversion="2016"
     connection="tech_cxn"
     formBasedAuthentication="true"
     formBasedAuthenticationURL="https://outlook.office365.com/owa/auth/owaauth.dll">

<!--- This works fine, too --->
<cfexchangemail
    action = "get"
    name = "FindMail"
    connection = "tech_cxn">

    <cfexchangefilter name="Folder" value="Inbox"> 
    <cfexchangefilter name="MessageType" value="Mail"> 
    <cfexchangefilter name="maxRows" value="10"> 
</cfexchangemail>
<cfdump var="#FindMail#">

<!--- 
If we include this code, all we get is: Failure
It even 'bypasses' the display of the CFDump, above.
Nothing in the CF logs, either. 
--->
<cfloop query="FindMail">
	<cfif FindMail.HasAttachment IS "Yes">
		<cfexchangemail
            action = "getAttachments"
            name = "myMailAttachments"
            uid = "#FindMail.uid#"
            connection = "tech_cxn"
            folder="Inbox"
            attachmentpath="C:\temp"
            generateUniqueFilenames="true">

            <cfdump var="#myMailAttachments#">
	</cfif>
</cfloop>

 

 Following documentation here:

https://helpx.adobe.com/coldfusion/developing-applications/using-external-resources/interacting-with-microsoft-exchange-servers/getting-exchange-items-and-attachments.html

This topic has been closed for replies.
Correct answer sdsinc_pmascari

Answered my own question.  It appears my install of CF did not have permission to write the C:\temp.  This also failed when I tried to save the attachments to S3.  However, when I changed the attachmentpath to: GetTempDirectory() it worked just fine.

 

An error a little more descriptive than "Failure" might have saved me the headache.

 

 

<cfexchangemail
            action = "getAttachments"
            name = "myMailAttachments"
            uid = "#FindMail.uid#"
            connection = "tech_cxn"
            folder="Inbox"
            attachmentpath="#GetTempDirectory()#"
            generateUniqueFilenames="true">

 

1 reply

sdsinc_pmascariAuthorCorrect answer
Legend
April 24, 2020

Answered my own question.  It appears my install of CF did not have permission to write the C:\temp.  This also failed when I tried to save the attachments to S3.  However, when I changed the attachmentpath to: GetTempDirectory() it worked just fine.

 

An error a little more descriptive than "Failure" might have saved me the headache.

 

 

<cfexchangemail
            action = "getAttachments"
            name = "myMailAttachments"
            uid = "#FindMail.uid#"
            connection = "tech_cxn"
            folder="Inbox"
            attachmentpath="#GetTempDirectory()#"
            generateUniqueFilenames="true">