I was concerned about how threads can be used in Coldfusion. Actually I am using 'cfmail' tag to send a mail with an attachment and I am storing the attachment file in a directory. What happens to be in the code is that, After using the cfmail tag I am deleting the directory. When I check the mail for the attachments it is not there. I think the mail could not be sent before the directory is deleted. Mail could not be sent prior to directory deletion. PLease comment !

I think the mail could not be sent before the directory is deleted.

No, not if you're using spooling. With spooling mail is sent via a separate thread and may be sent after you delete the file. If you read the docs on cfmail that's the expected behavior (see below). If you're on 8.0.1+, a better option is to use <cfmailparam content="..."> instead.

http://livedocs.adobe.com/coldfusion/8/Tags_m-o_01.html
Note: The cfmail tag does not make copies of attachments when spooling mail to disk. If you use the cfmail tag to send a message with an attachment with spooling enabled and you use the cffile tag to delete the attachment file, ColdFusion might not send the mail because the mailing process might execute after the file was deleted. ....

Hi arrgh,
Thanks for your comment ! I am posting my code for your better understanding. Have a look

<cfmail to="#arguments.to#" from="sender_email_id"
cc="#arguments.cc#" bcc="#arguments.bcc#" subject="#arguments.subject#"
replyto="sender_email_id" >
<cfoutput>#HTMLEditFormat(arguments.message)#</cfoutput>
<cfif ListLen(attachList) gt 0>
<cfloop index="i" list="#attachList#">
<cfmailparam file="#i#" disposition="attachment" >
</cfloop>
</cfif>
</cfmail>

I am checking if any attachment exists then only the loop will iterate through the attachments and I am also using cfmailparam tag. Your comment awaited !

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.