0

I am using TMail to send emails. I'm able to attach PDFs to these emails, and download them successfully. However, when I receive the email, the attachment name is 'noname'. How can I choose the name of the attachment? I know I can choose it using the mail gem.

At this point, I'm too far in the project to switch to anything else.

theIV
  • 25,434
  • 5
  • 54
  • 58

1 Answers1

0

When you create the message you do something like:

email = TMail::Mail.new

To attach your file you do something like:

attachment = TMail::Mail.new
attachment.body = Base64.encode64(attachment_content.to_s)
attachment.transfer_encoding = "Base64"
attachment['Content-Disposition'] = "attachment; filename=#{attachment_filename}"
email.parts << attachment

It's the next to last line that should do the trick.

the Tin Man
  • 158,662
  • 42
  • 215
  • 303