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. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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) On Jun 18, 1:32 pm, Ryan <miller2...-Wuw85uim5zDR7s880joybQ@public.gmane.org> wrote:> I''m running rails 2.0.2. I am trying to send anemailusing the > ActionMailer. Theemailis delivered when sending with or without an > attachment. My problem is that when I send an attachment, thebodyof > theemailis blank. I only get anemailwith 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 anemailwith an attachment, but mybodycontent > is missing.--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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 On Jul 3, 5:11 pm, Jon Pospischil <pospisc...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I am having exactly the same issue. > > Looking at the output, it seems that sending with an attachment simply > overwrites thebodysection of theemail... > > Anyone know what the reason is? > > (I am also running rails 2.0.2) > > On Jun 18, 1:32 pm, Ryan <miller2...-Wuw85uim5zDR7s880joybQ@public.gmane.org> wrote: > > > I''m running rails 2.0.2. I am trying to send anemailusing the > > ActionMailer. Theemailis delivered when sending with or without an > > attachment. My problem is that when I send an attachment, thebodyof > > theemailis blank. I only get anemailwith 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 anemailwith an attachment, but mybodycontent > > is missing.--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---