Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

cmail and cfmailparam - file delete problem 1

Status
Not open for further replies.

aliashippysmom

Programmer
Jul 29, 2004
43
US
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:
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>

 
Add this attribute to CFMAIL tag:
spoolenable ="no"
This will send your email instantly w/o spooling it first.
The problem you are having is while your email sits in Spool directory , you deleted it so by the time it's ready to be sent the file is no longer there.

hope this helps
liz
 
You rock! That worked great!!! Hadn't learned about spoolenable yet! Thank you very much.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top