Skip to main content
Inspiring
July 15, 2009
Answered

Deleting Files with CFThread

  • July 15, 2009
  • 1 reply
  • 673 views

From what I understand, my file should be deleted whenever the mail is done being sent.  However, the file is not being deleted.  Am I missing something?  I need to use threading because if I just try to send the file then delete it, the file is not found.

<cfthread action="run" name="send_mail">
      <cfmail to="#to#" from="#from#"  subject="Report">
            <cfmailparam file="#filename#.pdf">
#variables.text#
     </cfmail>
</cfthread>
<cfthread action="join" name="send_mail">
     <cffile action="delete" file="#filename#.pdf">
</cfthread>

Thanks!

    This topic has been closed for replies.
    Correct answer craigkaminsky

    If you want cfmail/cfmailparam to delete your file, you do have to add remove="true" to the cfmailparam tag. The timing of your mail being sent and the file being deleted can be tricky because CF does not just send the mail. It gets spooled and then sent (so threading may not be suitable to achieve your goals).

    The remove attribute was added in 8.0.1 and, from what I can tell, even the CF LiveDocs aren't updated with it yet ! Ben Nadel has a very good post on it:

    http://www.bennadel.com/blog/1214-New-ColdFusion-CFMailParam-Remove-Attribute-Makes-Deleting-Attachments-Simple.htm

    Hope this helps!!

    1 reply

    craigkaminskyCorrect answer
    Inspiring
    July 15, 2009

    If you want cfmail/cfmailparam to delete your file, you do have to add remove="true" to the cfmailparam tag. The timing of your mail being sent and the file being deleted can be tricky because CF does not just send the mail. It gets spooled and then sent (so threading may not be suitable to achieve your goals).

    The remove attribute was added in 8.0.1 and, from what I can tell, even the CF LiveDocs aren't updated with it yet ! Ben Nadel has a very good post on it:

    http://www.bennadel.com/blog/1214-New-ColdFusion-CFMailParam-Remove-Attribute-Makes-Deleting-Attachments-Simple.htm

    Hope this helps!!

    kodemonkiAuthor
    Inspiring
    July 15, 2009

    Amazing!  Thank you so much