4

I have a simple cfmail with an attachment. The file on the server has one name, but I'd like to call it something else when attached to the email. I tried:

<CFMAILPARAM FILE="#OriginalFile#" DISPOSITION="attachment; filename=""#AttachFile#""">

That works in certain email clients:

  • Thunderbird - All good
  • Outlook - No
  • Yahoo (on desktop) - No
  • Yahoo (on android) - Yes
  • GMail - Yes

Is there anyway, regardless of email client, I can get it to use the filename I want?!

Leigh
  • 28,765
  • 10
  • 55
  • 103
luke
  • 415
  • 1
  • 4
  • 14
  • You could always make a copy with the name you want. – Dan Bracuk Jun 15 '16 at 19:08
  • @DanBracuk i guess i could do, and may have to, but i'd like to avoid if possible. this cfmail is part of a larger process that is generating a few hundred pdf files, naming them from their unique database reference id ( to avoid any possible duplicate filenames ) and them emailing them out. – luke Jun 15 '16 at 19:16
  • (Edit) Out of curiosity, what file name do the other clients use instead? Related [Change filename of attachments on Coldfusion](http://stackoverflow.com/questions/34865183/change-filename-of-attachments-on-coldfusion). I realize you want to avoid renaming, but typically the file name is a "suggestion" to the client. I am not sure it is possible to enforce it. – Leigh Jun 15 '16 at 19:16
  • 3
    See [RFC 2183](https://tools.ietf.org/html/rfc2183) *"..The sender may want to suggest a filename ... It is important that the receiving MUA not blindly use the suggested filename.*" – Leigh Jun 15 '16 at 20:43
  • @Leigh the filename used is #OriginalFile# where #AttachFile# is ignored. i guess that rfc makes sense, you wouldn't want people to able to be send you an executable for example, but pretend its something else. thanks. – luke Jun 15 '16 at 23:30
  • @luke - Exactly. I suspect that is why they noted it as a suggestion for mail clients, not a mandate. Only other thing I can think of would be to try reading in the file into a variable, and using the `content` variable instead of `file`. If that does not work, you may be out of luck and will have to use a temp file and delete it (as mentioned on the link above). – Leigh Jun 16 '16 at 01:41
  • I nominate @Leigh to post her comment about RFC 2813 as an answer. – Dan Bracuk Jun 16 '16 at 12:32
  • First I would be curious to know what effect (if any) using `content` instead of `file` had with the problem mail clients above. Also, what was the result of using a physical `file` (with the desired name) with those same clients. – Leigh Jun 16 '16 at 17:58
  • if anyone reads this looking for a solution, i was just reading that in cf2016 theres a new cfmailparam attribute called filename 'The file name of the attachment as seen by the recipient.' unfortunately i'm not on 2016 yet – luke Aug 27 '16 at 01:31

0 Answers0