Copy link to clipboard
Copied
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:
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"
...
Copy link to clipboard
Copied
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">