ActionMailer multipart messages with attachment rails3

Hi,

I try to send a multipart message with actionmailer under rails3. When the mail client receives the mail the attachment is empty. I do definitely attach a non-empty file. Here is the code:

snip

recipients ["secret@secret.com"] from "secret@secret.com" subject "my subject"

attachments.inline['pict.png'] =    File.read File.join(Rails.root, 'public/images/pict.png') #works fine

   part(:content_type => "multipart/alternative") do |p|       p.part :content_type => "text/plain", :body => render("verwertung.text.haml")       p.part :content_type => "text/html", :body => render("verwertung.html.haml")   end

attachment :content_type => "text/csv",            :filename => "verwertung.csv",            :body => File.read('/tmp/verwertung.csv')

snip

The mail looks fine, e.g. the inline attachment is included, but the attached file is empty!

What is the problem here?

Best regards, Thomas

Thomas Grebschrop wrote in post #950122:

Hi,

I try to send a multipart message with actionmailer under rails3. When the mail client receives the mail the attachment is empty. I do definitely attach a non-empty file. Here is the code:

snip

recipients ["secret@secret.com"] from "secret@secret.com" subject "my subject"

attachments.inline['pict.png'] =    File.read File.join(Rails.root, 'public/images/pict.png') #works fine

   part(:content_type => "multipart/alternative") do |p|       p.part :content_type => "text/plain", :body => render("verwertung.text.haml")       p.part :content_type => "text/html", :body => render("verwertung.html.haml")   end

attachment :content_type => "text/csv",            :filename => "verwertung.csv",            :body => File.read('/tmp/verwertung.csv')

snip

The mail looks fine, e.g. the inline attachment is included, but the attached file is empty!

What is the problem here?

Best regards, Thomas

I did now attachments['verwertung.csv'] = {:content => csv_content }

and it worked.

Thomas