I'm trying to use ColdFusion to send out emails containing attachments stored on our server.
To manage these attachments we call them 1.jpg
, 2.doc
... n.ext
where n
is a key in a database where we hold other information about the file such as its original filename.
I can use the code:
<cfmailparam file="c:\path\1.doc">
to specify the file, but it is then attached to the email as 1.doc
. Is there anyway I can override this and specify my own filename separately from the file?
ColdFusion 2016 added this new attribute called filename to override the filename specified in the file attribute. A sample example is below
<cfmail from="[email protected]" subject="filename test" to="[email protected]" username="[email protected]" password="password" server="localhost" spoolenable="false">
<cfmailparam file="c:\Book2.xlsx" filename="Offers.xlsx">
Check out the new offers sheet
</cfmail>
Now when the mail is sent to the user he/she will see this as Offers.xslx instead of Book2.xslx. More info at https://tracker.adobe.com/#/view/CF-4019518