Trouble with email attachments

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:

attachment :content_type => “image/jpeg”,
:body => File.read(“an-image.jpg”)

attachment “application/pdf” do |a|
a.body = File.read(“an-image-.jpg”)
end

Both ways result in an email with an attachment, but my body content
is missing.

I am having exactly the same issue.

Looking at the output, it seems that sending with an attachment simply
overwrites the body section of the email…

Anyone know what the reason is?

(I am also running rails 2.0.2)

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

part :content_type => "text/html", :body =>

render_message(“invoice”, :variable1 => value, :variable2 => value)

Hope this helps!
Jon