ruby rails
2013-Sep-29 07:11 UTC
body of email not displaying with attachments in rails2.3.5
I am sending an email through my application to other user''s gmail id. I am receiving email and it works fine without attachment. But when I attach a file, the mail which users receive contain subject and attachments only. The body part is not displaying in the mail. In the controller I am passing everything as params to reminder_email method. I am using rails2.3.5..This is how I have implemented in my mailer.rb file. Please help. class ReminderMailer < ActionMailer::Base def reminder_email(sender,recipients, subject, message,attachments) recipient_emails = (recipients.class == String) ? recipients.gsub('' '','''').split('','').compact : recipients.compact setup_reminder_email(sender, recipient_emails, subject, message,attachments) end protected def setup_reminder_email(sender, emails, subject, message,files) @from = sender @recipients = emails @subject = subject @sent_on = Time.now @body[''message''] = message #content_type = "multipart/alternative" files.each do |file| attachment "application/octet-stream" do |a| a.body = file.read a.filename = file.original_filename end unless file.blank? end end end -- 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 unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/d7f19b79cbc4d09b1152196405c06f58%40ruby-forum.com. For more options, visit https://groups.google.com/groups/opt_out.
pradeep83.achu-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2013-Sep-29 07:13 UTC
body of email not displaying with attachments in rails2.3.5
I am sending an email through my application to other user''s gmail id. I am receiving email and it works fine without attachment. But when I attach a file, the mail which users receive contain subject and attachments only. The body part is not displaying in the mail. In the controller I am passing everything as params to reminder_email method. I am using rails2.3.5..This is how I have implemented in my mailer.rb file. Please help. class ReminderMailer < ActionMailer::Base def reminder_email(sender,recipients, subject, message,attachments) recipient_emails = (recipients.class == String) ? recipients.gsub('' '','''').split('','').compact : recipients.compact setup_reminder_email(sender, recipient_emails, subject, message,attachments) end protected def setup_reminder_email(sender, emails, subject, message,files) @from = sender @recipients = emails @subject = subject @sent_on = Time.now @body[''message''] = message #content_type = "multipart/alternative" files.each do |file| attachment "application/octet-stream" do |a| a.body = file.read a.filename = file.original_filename end unless file.blank? end end end -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/dd9f5b73-1153-4ffb-bed7-2b2b0d94fd05%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
vikram jain
2013-Sep-30 04:34 UTC
Re: body of email not displaying with attachments in rails2.3.5
def email_with_attachments(application_fields={},files=[]) @headers = {} @sent_on = Time.now @recipients = ''client-9IKiO1iGCm/QT0dZR+AlfA@public.gmane.org'' @from = ''info-9IKiO1iGCm/QT0dZR+AlfA@public.gmane.org'' @subject = ''Here are some file attachments'' application_fields.keys.each {|k| @body[k] = application_fields[k]} # attach files files.each do |file| attachment "application/octet-stream" do |a| a.body = file.read a.filename = file.original_filename end unless file.blank? end end On Sun, Sep 29, 2013 at 12:41 PM, ruby rails <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> I am sending an email through my application to other user''s gmail id. I > am receiving email and it works fine without attachment. But when I > attach a file, the mail which users receive contain subject and > attachments only. The body part is not displaying in the mail. In the > controller I am passing everything as params to reminder_email method. I > am using rails2.3.5..This is how I have implemented in my mailer.rb > file. Please help. > > class ReminderMailer < ActionMailer::Base > > def reminder_email(sender,recipients, subject, > message,attachments) > recipient_emails = (recipients.class == String) ? > recipients.gsub('' '','''').split('','').compact : recipients.compact > setup_reminder_email(sender, recipient_emails, subject, > message,attachments) > end > > protected > def setup_reminder_email(sender, emails, subject, message,files) > @from = sender > @recipients = emails > @subject = subject > @sent_on = Time.now > @body[''message''] = message > #content_type = "multipart/alternative" > files.each do |file| > attachment "application/octet-stream" do |a| > a.body = file.read > a.filename = file.original_filename > end unless file.blank? > end > end > end > > -- > 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 unsubscribe from this group and stop receiving emails from it, send an > email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To view this discussion on the web visit > https://groups.google.com/d/msgid/rubyonrails-talk/d7f19b79cbc4d09b1152196405c06f58%40ruby-forum.com > . > For more options, visit https://groups.google.com/groups/opt_out. >-- Thanks & Regard Vikram Jain ============ -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAJP0RPyPEaHHB4o_vnA%2BTbFWrmdnRNEu2XRwwVWtTLS%3DNbttfg%40mail.gmail.com. For more options, visit https://groups.google.com/groups/opt_out.