Hello, I'm trying to create a function to send mail with an attached
file. After an hour reading rails documentation and a few intents I
can't figure out this error:

undefined local variable or method 'attachments' for Emailer:Class

Here comes the code of the mail creation function:

class Emailer < ActionMailer::Base
   ...
   def Emailer.sendMailBCCWithAttachments(recipient, subject, message,
from, newsletter)
       attachments[newsletter.filename] = File.read("#{RAILS_ROOT}/
public#{newsletter.filepath}")

       mail(
         :subject => subject,
         :bcc => recipient,
         :from => from,
         :content_type => "text/html; charset=utf-8",
         :body => message,
         :sent_on => Time.now
       )
   end
   ...
end

And here is how I use it:
# Create the mail
mail = Emailer.sendMailBCCWithAttachments(recipients,
newsletter.subject, message, "newslet...@winecorner.com", newsletter)
# Sends it
mail.deliver

Any idea?

-- 
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@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to