Community,
I’m struggling with an issue and I’m sure it is trivial but I cannot
find the solution. I’m trying to attach a PDF file to an email. For
simplicity, I have explicitely named a given file but when I get the
email, the attachment is only a partial of the document which causes it
to be corrupt. Sample below:
@recipients = ‘[email protected]’
@from = “Test [email protected]”
@subject = “My Subject”
fileName = “#{RAILS_ROOT}/documents/test.pdf”
attachment :content_type => “application/pdf”,
:content_disposition => “attachment”,
:body => File.read(fileName)
I’m using the testMail = MyMailer.create_test_mail followed by
MyMailer.deliver(testMail) process and the email is being sent, along
with an attachment but the attachment is only about half of the actual
original file size. The beginning part of the file appears to be
correct - but for some reason, the entire file isn’t being sent.
Any ideas? Also, how do I name the attachment? It is coming across
as Part 1.1.
Your help is greatly appreciated! I have followed various examples
found on the web and ROR site but apparently am missing something basic!
Thanks,
Michael