问题
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 nameASSET_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?
回答1:
There are a few ways you could do this
- You could rename the files themselves
- Create duplicates and then use the
remove="true"
attribute of cfmailparam - Read the files with the odd names and attach them with a new name
<cfmailparam file="niceName.pdf" content="#fileRead(oddName.pdf)#">
来源:https://stackoverflow.com/questions/34865183/change-filename-of-attachments-on-coldfusion