Converting old Mailer to Rails 3 (multipart/mixed)

Posted by Oscar Del Ben on Stack Overflow See other posts from Stack Overflow or by Oscar Del Ben
Published on 2010-12-29T15:03:00Z Indexed on 2010/12/29 17:54 UTC
Read the original article Hit count: 254

Filed under:

I'm having some difficulties converting this old mailer api to rails 3:

content_type "multipart/mixed"

part :content_type => "multipart/alternative" do |alt|

  alt.part "text/plain" do |p|
     p.body = render_message("summary_report.text.plain.erb",

:message => message.gsub(/<.br.>/,"\n"), :campaign=>campaign, :aggregate=>aggregate, :promo_messages=>campaign.participating_promo_msgs) end

   alt.part "text/html" do |p|
      p.body = render_message("summary_report.text.html.erb",

:message => message, :campaign=>campaign, :aggregate=>aggregate,:promo_messages=>campaign.participating_promo_msgs) end

end
if bounce_path
  attachment :content_type => "text/csv",
  :body=> File.read(bounce_path),
  :filename => "rmo_bounced_emails.csv"
end
attachment :content_type => "application/pdf",
      :body => File.read(report_path),
      :filename=>"rmo_report.pdf"

In particular I don't understand how to differentiate the different multipart options. Any idea?

© Stack Overflow or respective owner

Related posts about ruby-on-rails