Search code examples
coldfusioncoldfusion-8

How do I attach a file from a server in a mail using coldfusion8?


This is my code to get the file from user and attach it to the mail.

<cfset destination = expandPath('Uploads/')>
<cffile action='upload' filefield='file_upload' destination='#destination#'       result='upload' >
<cfmail to="id" from="id" subject="test">
<cfmailparam file="destination">
</cfmail>

When I run this I get an error, The resource destination was not found. Could you please help?


Solution

  • You can do some thing like this

     <cfset destination = expandPath('Uploads/')>
    <cffile action='upload' filefield='file_upload' destination='#destination#'       result='upload' >
    <cfmail to="#id#" from="#id#" subject="test">
    <cfmailparam file="#destination#/#upload.serverFile#" >
    </cfmail>
    

    For more information you can see cfmailparan and cffile action="upload"