yasint
yasint

Reputation: 31

Change filename of attachments on Coldfusion

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:

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?

Upvotes: 3

Views: 456

Answers (1)

Matt Busche
Matt Busche

Reputation: 14333

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)#">

Upvotes: 4

Related Questions