Thomas Grebschrop
2010-Oct-14 12:05 UTC
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:>sniprecipients ["secret-yg6Xurl4js7QT0dZR+AlfA@public.gmane.org"] from "secret-yg6Xurl4js7QT0dZR+AlfA@public.gmane.org" 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'')>snipThe mail looks fine, e.g. the inline attachment is included, but the attached file is empty! What is the problem here? Best regards, Thomas -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Thomas Grebschrop
2010-Oct-15 07:37 UTC
Re: ActionMailer multipart messages with attachment rails3
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-yg6Xurl4js7QT0dZR+AlfA@public.gmane.org"] > from "secret-yg6Xurl4js7QT0dZR+AlfA@public.gmane.org" > 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, > ThomasI did now attachments[''verwertung.csv''] = {:content => csv_content } and it worked. Thomas -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.