Changing the file name in ColdFusion

I use cfmailparamto attach files to email. I get file names and paths from my database. Attached files usually have unique names, but I can get their original file names by querying the following columns in the database table:

  • ASSET_FILE_NAME: unique name
  • ASSET_REAL_NAME: original_name_before_upload.pdf

When I send an email using cfmail, the attachments still use unique names, but I really need to rename them. I also searched and tried:

<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 does not work for all attachment files. It changes only one file name, and the rest still use unique names.

Is there any way to make this possible?

+3
source share
1

.

  • , remove="true" cfmailparam
  • <cfmailparam file="niceName.pdf" content="#fileRead(oddName.pdf)#">
+4

All Articles