aliashippysmom
Programmer
HI!
We recently switched to CF MX7 and I have a question. I have a mail script which allows users to select a distribution list for an email. They can also attach up to 3 files to the email. For MX7, when I run this, it works o.k. as long as I don't delete the files after I upload them. Typically, I: (1) upload the file(s), (2) send the email with file(s) attached, and then (3) delete files from the server. Works great as long as I don't delete the files after email transmission. I received an error in the mail log file which said "file not found"...Can anyone help? Thanks! Here's what I have so far:
We recently switched to CF MX7 and I have a question. I have a mail script which allows users to select a distribution list for an email. They can also attach up to 3 files to the email. For MX7, when I run this, it works o.k. as long as I don't delete the files after I upload them. Typically, I: (1) upload the file(s), (2) send the email with file(s) attached, and then (3) delete files from the server. Works great as long as I don't delete the files after email transmission. I received an error in the mail log file which said "file not found"...Can anyone help? Thanks! Here's what I have so far:
Code:
<cfset filelist = "">
<CFSET thisPath= ExpandPath("*.*")>
<CFSET thisDirectory= GetDirectoryFromPath(thisPath)>
<CFTRY>
<cfif #form.filename1# IS NOT "">
<CFFILE ACTION="UPLOAD"
FILEFIELD="FORM.filename1"
DESTINATION="#thisDirectory#"
NAMECONFLICT="Overwrite">
<cfset filename1 = "#CFFILE.ServerDirectory#\#CFFILE.ServerFile#">
<cfset filelist = ListAppend(filelist,#filename1#)>
</cfif>
<cfif #form.filename2# IS NOT "">
<CFFILE ACTION="UPLOAD"
FILEFIELD="FORM.filename2"
DESTINATION="#thisDirectory#"
NAMECONFLICT="Overwrite">
<cfset filename2 = "#CFFILE.ServerDirectory#\#CFFILE.ServerFile#">
<cfset filelist = ListAppend(filelist,#filename2#)>
</cfif>
<cfif #form.filename3# IS NOT "">
<CFFILE ACTION="UPLOAD"
FILEFIELD="FORM.filename3"
DESTINATION="#thisDirectory#"
NAMECONFLICT="Overwrite">
<cfset filename3 = "#CFFILE.ServerDirectory#\#CFFILE.ServerFile#">
<cfset filelist = ListAppend(filelist,#filename3#)>
</cfif>
<cfmail
query="getadd"
to="#mem_email#"
from="#form.from#"
subject="#form.subject#">
<cfif filename1 IS NOT "">
<cfmailparam file="#filename1#">
</cfif>
<cfif filename2 IS NOT "">
<cfmailparam file="#filename2#">
</cfif>
<cfif filename3 IS NOT "">
<cfmailparam file="#filename3#">
</cfif>
#form.body#
</cfmail>
<p>Your email has been sent successfully to the following:</P>
<cfoutput query="getadd">
#CurrentRow# #mem_last_name# #mem_first_name#<br>
</cfoutput>
<!--- delete uploaded files, if necessary --->
[COLOR=red]If I comment out the following, it works ok [/color]
<cfif filename1 is not "">
<CFFILE ACTION="DELETE"
FILE="#filename1#">
</cfif>
<cfif filename2 is not "">
<CFFILE ACTION="DELETE"
FILE="#filename2#">
</cfif>
<cfif filename3 is not "">
<CFFILE ACTION="DELETE"
FILE="#filename3#">
</cfif>
<CFCATCH TYPE="Any">
You have encountered an error sending this email, please try it again.
</CFCATCH>
</cftry>