Search code examples
coldfusioncoldfusion-9cfmail

Error attempting to send mail with attachment using CFMail


I am trying to send an email with an attached file to it but I am getting an error that I am not familiar with.

This is my code for the <cfmail> tag:

<CFMAIL FROM="test@test.com" TO="test2@test2.com"  SUBJECT="Test" type="HTML">
<P> This is the attachments test</P>
<p> For this test to be successful, we need to receive some file attachments with this email</p>
  <cfsilent>
    <cfloop query="result">

        <cfmailparam file="#result.NAME#" disposition="attachment">

    </cfloop>
  </cfsilent>
</cfmail>

And this is the error:

The resource 2011093475839213.txt was not found.

**The root cause was: ''.**

The error occurred in E:\sites\Example.Com\FolderExistsTest.cfm: line 71
69 :     <cfloop query="result">
70 :       
71 :         <cfmailparam file="#result.NAME#" disposition="attachment" type="text">
72 :     
73 :     </cfloop>

Please note that the file I am trying to attach does exist.


Solution

  • This is the correct way to specify the path for the file.

       <cfmailparam file="#CurrentDirectory#\#result.NAME#" disposition="attachment" type="text">