I’m running rails 2.0.2. I am trying to send an email using the
ActionMailer. The email is delivered when sending with or without an
attachment. My problem is that when I send an attachment, the body of
the email is blank. I only get an email with an attachment.
I’ve tried a couple different ways using the attachment method:
For anyone else, the trick here is (from the Rails API Docs):
Implicit template rendering is not performed if any attachments or
parts have been added to the email. This means that you‘ll have to
manually add each part to the email and set the content type of the
email to multipart/alternative.
what this means is that we have to define the parts ourselves if we
add attachments:
attachment :content_type => ‘application/vnd.ms-excel’, :filename
=> ‘invoice.xls’, :body => invoice_body