Hi all, I have an app that sends out a few e-mail notifications. Most of them work except for this one, which send a blank e-mail and an attached letter that was created using ERB. def donation_notification state, letter recipients @state.email subject ''Donation Notification'' from ''admin-9IKiO1iGCm/QT0dZR+AlfA@public.gmane.org'' body :state => state attachment ''application/rtf'' do |a| a.body = letter a.filename = ''letter.rtf'' end end The ''letter'' variable is a bound ERB template that''s created when I call donation_notification from my controller. Like this: Notifier.deliver_donation_notification @state, _letter And _letter is a partial that looks like this: def _letter ERB.new(File.read ''./app/views/notifier/letter.rtf'').result (binding) end So letter.rtf is generated fine, but the body of the e-mail is blank. I''m guessing this has to do with ERB being used by actionmailer as well. But that''s only a guess, I''m not sure why this is happening. Could anyone explain and perhaps offer a solution? Thanks, Dave -- 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.
Another thing to note. If I specify the body as a string it works: def donation_notification state, letter recipients @state.email subject ''Donation Notification'' from ''ad...-9IKiO1iGCm/QT0dZR+AlfA@public.gmane.org'' body ''This will be seen as the e-mail''s body and the attachment will come through as well!'' attachment ''application/rtf'' do |a| a.body = letter a.filename = ''letter.rtf'' end end Certainly this is a work around, but not very clean. On Dec 9, 4:53 pm, Dave <dsu...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi all, > > I have an app that sends out a few e-mail notifications. Most of them > work except for this one, which send a blank e-mail and an attached > letter that was created using ERB. > > def donation_notification state, letter > recipients @state.email > subject ''Donation Notification'' > from ''ad...-9IKiO1iGCm/QT0dZR+AlfA@public.gmane.org'' > body :state => state > attachment ''application/rtf'' do |a| > a.body = letter > a.filename = ''letter.rtf'' > end > end > > The ''letter'' variable is a bound ERB template that''s created when I > call donation_notification from my controller. Like this: > > Notifier.deliver_donation_notification @state, _letter > > And _letter is a partial that looks like this: > > def _letter > ERB.new(File.read ''./app/views/notifier/letter.rtf'').result > (binding) > end > > So letter.rtf is generated fine, but the body of the e-mail is blank. > I''m guessing this has to do with ERB being used by actionmailer as > well. But that''s only a guess, I''m not sure why this is happening. > > Could anyone explain and perhaps offer a solution? > > Thanks, > Dave-- 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@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Found my answer: http://www.elctech.com/articles/-actionmailer-multipart-emails-with-attachments Dave On Dec 10, 10:04 am, Dave <dsu...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Another thing to note. If I specify the body as a string it works: > > def donation_notification state, letter > recipients @state.email > subject ''Donation Notification'' > from ''ad...-9IKiO1iGCm/QT0dZR+AlfA@public.gmane.org'' > body ''This will be seen as the e-mail''s body and the > attachment will come through as well!'' > attachment ''application/rtf'' do |a| > a.body = letter > a.filename = ''letter.rtf'' > end > end > > Certainly this is a work around, but not very clean. > > On Dec 9, 4:53 pm, Dave <dsu...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Hi all, > > > I have an app that sends out a few e-mail notifications. Most of them > > work except for this one, which send a blank e-mail and an attached > > letter that was created using ERB. > > > def donation_notification state, letter > > recipients @state.email > > subject ''Donation Notification'' > > from ''ad...-9IKiO1iGCm/QT0dZR+AlfA@public.gmane.org'' > > body :state => state > > attachment ''application/rtf'' do |a| > > a.body = letter > > a.filename = ''letter.rtf'' > > end > > end > > > The ''letter'' variable is a bound ERB template that''s created when I > > call donation_notification from my controller. Like this: > > > Notifier.deliver_donation_notification @state, _letter > > > And _letter is a partial that looks like this: > > > def _letter > > ERB.new(File.read ''./app/views/notifier/letter.rtf'').result > > (binding) > > end > > > So letter.rtf is generated fine, but the body of the e-mail is blank. > > I''m guessing this has to do with ERB being used by actionmailer as > > well. But that''s only a guess, I''m not sure why this is happening. > > > Could anyone explain and perhaps offer a solution? > > > Thanks, > > Dave-- 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@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.