CFFILE and CFMAIL not playing nice together!

I have a page that collects a file upload and emails it to a local customer service agent. I would like to delete the file on the server afterwards, but in doing so, it seems like the email and attached file are not sent–and no error condition is raised! Can someone tell me if I’m doing things in the right order or way? Here’s the code (oh, BTW, we are stuck on CF 6.1 here :-P); TIA for your help!

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
	<title>Email Your Verification of Training</title>
<cfif IsDefined("form.verification")>
	<cfset errUpload = "false" />
    <cftry>
    	<cffile action="upload" filefield="verification" destination="/somefolder/" nameconflict="makeunique" />
        <cfcatch>
        	<script type="text/javascript">
				alert('There was a problem in uploading your document.');
			</script>
            <cfset errUpload = "true" />
        </cfcatch>
	</cftry>
    <cfif errUpload EQ "false">
    	<cftry>
            <cfmail to="#constants.emailInfo#" cc="#constants.emailTechnical#" from="#session.userinfo.email#" subject="Verification of Training for member no. #session.userinfo.id#">
Verification of Training: #form.name#, member no. #session.userinfo.id#
====================================

The applicant has submitted the attached documentation to verify
his or her completion of training.  Please update the
applicant's records in the #constants.appAcronym# database to reflect this.
                <cfmailparam file="#cffile.serverDirectory#\\#cffile.serverFile#" />
            </cfmail>
            <cfcatch>
            	<script type="text/javascript">
					alert('Sorry! We did not receive your documentation.');
				</script>
                <cfset errUpload = "true" />
            </cfcatch>
        </cftry>
<!--- The following is the try/catch statement that seems to stop email from being sent while failing to throw an error condition. --->
        <cftry>
	        <cffile action="delete" file="#cffile.serverDirectory#\\#cffile.serverFile#" />
            <cfcatch>
            	<script type="text/javascript">
					alert('We did receive your documentation, but were unable to delete a copy of it on our servers.');
				</script>
            </cfcatch>
        </cftry>
    </cfif>
</cfif>
</head>
<body>
	<cfoutput>
        <h2>Submit Your Verification of Training</h2>
		<cfif IsDefined("form.verification") AND errUpload EQ "false">
        	<p><strong>Thank you!</strong> Your documentation has been received, and should be posted 
            online within 2-3 business days.<br />
            <a href="javascript:self.close();">Close window</a></p>
        <cfelseif IsDefined("form.verification") AND errUpload EQ "true">
        	<p><strong>Sorry!</strong> At some point, we were unable to receive your documentation. Please send your documentation through your regular email program to:</p>
            <p><strong><a href="mailto:<cfoutput>#constants.emailInfo#&subject=Verification%20of%20Training%20for%20member%20no.%20#session.userinfo.id#</cfoutput>"><cfoutput>#constants.emailInfo#</cfoutput></a></strong></p>
            <p>On the Subject line, remember to refer to <cfoutput>Verification of Training and your member number #session.userinfo.id#</cfoutput>.<br />
            <a href="javascript:self.close();">Close window</a></p>
        <cfelse>
		<form
			action="#CGI.script_name#"
			method="post"
			enctype="multipart/form-data">
			<!--- Our form submission flag. --->
			<input type="hidden" name="submitted" value="1" />

			<p>Click the first button below to find your verification of spirometry training document  on your computer. After you have found and selected the document, click the &ldquo;Upload and email my document&rdquo; button to submit it.</p>

				<input
					type="hidden"
					name="id"
					id="id"
					value="#session.userinfo.id#"
					/>

				<input
					type="hidden"
					name="name"
					id="name"
					value="#session.userinfo.namelast#, #session.userinfo.namefirst#"
					/>

				<input
					type="hidden"
					name="email"
					id="email"
					value="#session.userinfo.email#"
					/>

 			<p>
			<label for="verification">
				Verification of training document:
			</label>
				<input
					type="file"
					name="verification"
					id="verification"
					/>
			</p>

			<input type="submit" value="Upload and email my document" />
		</form>
        </cfif>
	</cfoutput>
</body>
</html>

Emails aren’t necessarily sent right away. They’re placed in a mail queue. So you can’t delete the files until after the email is sent.

I don’t think 6.1 allows you to send dynamic attachments ie without using files. (There might be custom tags that do …) You could place the files in special directory, and use a scheduled task to delete them periodically. ie Delete files older than yesterday. Unfortunately, that’s all I’ve got for 6.1.

Many thanks, that’s what I needed to know! I think I’ll just save to a location outside of the Web root; on the internal side of the app, I’ll use <cffile action=“move”> to archive the files once an agent reviews them.