Forum: Ruby how to attach more files as attachment file in email using gmail_sender

Posted by Edward QU (autogyro)
on 2012-09-25 12:38
Dear ALL
I want to develop a script to attach more files as attachment file in an
email, using gmail_sender.


def send_mail(recipients,subject,message,email_author,attach_files)
  begin
    email_content="Dear Receiver: \nThis email was sent by
#{email_author} automatically.\n"
    email_content+= "#{message}\n"
    email_content+= "\nPlease check attached files for
detail!\nRegards\n#{email_author}\n#{Time.now.to_s}\n"
    r= recipients
    s="#{subject} at #{Time.now}"
    c=email_content
g= GmailSender.new('***@gmail.com','pwd')
    g.attach(attach_files)
    g.send(:to => r, :subject => s, :content =>c)

  rescue Timeout::Error => time_out
    sent_status ="Time out or could not access internet."
  rescue Exception => error
    sent_status= "Exception occured:  #{error}"
  end
end


Find.find(attach_file_folder) do |f|
attached_files  << #{f}
end

how to make the attach_files work?
any help would be great appreciated!

Regards
Qu
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.