Change filename of attachments on Coldfusion

谁说我不能喝 提交于 2019-12-23 20:26:50

问题


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?


回答1:


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


来源:https://stackoverflow.com/questions/34865183/change-filename-of-attachments-on-coldfusion

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!