Reputation: 1
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.
Upvotes: 0
Views: 430
Reputation: 160551
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.
Upvotes: 0