3

I'm using cfmailparam to attach files to an email. I'm getting the filenames and paths from my database. Normally, the attached files have unique names, but I can get their original filenames by querying the following columns in a database table:

  • ASSET_FILE_NAME: unique name
  • ASSET_REAL_NAME: original_name_before_upload.pdf

When I send the e-mail with cfmail, the attachments still use the unique names, but I really need to rename them. I've searched and tried also:

<cfloop from="1" to="#assetfiles.RecordCount#" index="i">
    <cfmailparam
        file="C:\files\#assetfiles.ASSET_FILE_NAME[i]#"
        type="application/pdf"
        disposition="attachment; filename=""#assetfiles.ASSET_REAL_NAME[i]#"""
    />
</cfloop>

But this is not working for all attachment files. It changes just 1 filename and the other ones still use the unique names.

Is there anyway to make this possible?

Leigh
  • 28,765
  • 10
  • 55
  • 103
yasint
  • 31
  • 2

1 Answers1

4

There are a few ways you could do this

  1. You could rename the files themselves
  2. Create duplicates and then use the remove="true" attribute of cfmailparam
  3. Read the files with the odd names and attach them with a new name <cfmailparam file="niceName.pdf" content="#fileRead(oddName.pdf)#">
Matt Busche
  • 14,216
  • 5
  • 36
  • 61
  • Dear Matt Busche, thanks for your reply. I'm trying it now. I'll be write again result if success or not. Thanks again. – yasint Jan 19 '16 at 08:39
  • Option 2 worked for me. However, in my case option 3 created a correctly name attached but empty pdf file. Using CF9,0,1,274733. – Micah Oct 18 '17 at 18:16