def send_mail(person,textarea,subject,attachment_id) recipients person.email1 cc person.email2
from "some email address" subject subject content_type "text/html" body textarea
unless attachment_id.nil? @attachment = Attachment.find_by_id(attachment_id) filename = @attachment.filename.rstrip attachment @attachment.content_type do |a| a.filename = @attachment.filename a.body = File.read("c:\\inetpub\\event\\public\\data\\#{filename}") end end end
Hello Above is the code for sending attachment. Problems 1. Whenever i send an attachment, the attachment does not open in the recepients inbox.The recepient gets an exclaimation mark at the end of the filename in the attachment.
2. Also my email text (i.e body of the email) is in html format that does not appear in html format. If i remove the attachment part and set the content_type to "text/html" then the text appears in html format. But i want to send text in html format and also the attachment.
I believe there is something wrong with the way i have written content_type. Can anyone please help me.
Thank you.