I am not sure why the email that I send via ActionMailer with an attachment doesn’t show me the attachment instead the contents of the attachment is just shown / output into the email.
class MyMailer < ActionMailer::Base
default :from => "email@email.com"
def test_email()
attachments['testresult1.html'] = {
:filename => 'testresult1.html',
:body => File.read('C:\\testresult1.html')
}
mail(:to => 'email@email.com',
:subject => 'Cool great message'
)
end
end
The output of the email looks like this
Date: Tue, 17 Apr 2012 14:11:52 +1000
Mime-Version: 1.0
Content-Type: text/html;
charset=UTF-8;
filename=testresult1.html
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename=testresult1.html
filename: testresult1.html
Content-ID: <4f8ced883c0d9_1b1c30b580813e@PC-049.mail>
and then the whole contents of the HTML file/attachment.
I’d expect the HTML file to be attached to the email as it would be attached to a normal email and I should be able to double click on the attachment and open it in a browser.
Email Client = Microsoft Outlook
Connection = SMTP
Rails = 3.2.1
ActionMailer = 3.2.1
Mail = 2.4.4
You should try adding a
bodykey to #mail.