From: grooveska Date: 2007-06-09T06:10:31+09:00 Subject: Re: Help with emailing attachments with Ruby... I ended up just using mailfactory that was included with ruport-util, and it worked great. I may work on reformatting the csv file know that I have found a great tool for that task. So for anyone looking for help with email attachments here is what worked for me: 1. I had to get an updated copy of the smtp.rb file that included SSL/ TLS support since our smtp server requires SSL/TLS. Found that here: http://www.koders.com/ruby/fid4B13D002144D0985D12CB47DA041D8E59E0E8667.aspx?s=cdef%3asmtp%2bserver 2. Then here is my script: require 'net/smtp' require 'rubygems' require 'mailfactory' require 'date' require 'time' ################################################################## # This portion of the code assembles the filenames of the files # # to be attached in the email # ################################################################## time = Time.now #set time object to the current time month = time.month #grab the number of the month from the current time day = time.day #grab the day of the current time year = time.year #grab the year of the current time month = month + 1 #to match the format of file names if month < 10 #formatting fullmonth = "0" + month.to_s else fullmonth = month.to_s end if day < 10 fullday = "0" + day.to_s else fullday = day.to_s end #end of formatting filename = "pagecount-" + year.to_s + fullmonth + fullday + ".csv" #assemble file name filename1 = "send_report-" + year.to_s + fullmonth + fullday + ".csv" #assemble file name # # mail = MailFactory.new() mail.to = "xxx@xxx.xxx" mail.from = "sendername " mail.subject = "Insert your subject line here" mail.text = "Insert the body of the email text here." mail.attach("pathtofile" + filename) mail.attach("pathtofile" + filename1) toaddress = 'xxxx@xxx.xxx' fromaddress = 'xxxx@xxx.xxx' # Net::SMTP.enable_tls(OpenSSL::SSL::VERIFY_NONE) Net::SMTP.start('smtp.xxx.xx', '25', 'domain_name', 'userid', 'password', :plain) do |smtp| smtp.send_mail(mail.to_s(), fromaddress, toaddress) end Hopefully that will help some one out. On Jun 7, 4:34 pm, "Gregory Brown" wrote: > On 6/7/07, grooveska wrote: > > > That looks awesome. Nice and simple. I'm going to give that a try. > > Cool. If you run into any troubles, feel free to catch us on the ruport list:http://list.rubyreports.org