Welcome Guest | Login

Composing HTML e-mail with a PDF attachment

Hi, everyone.
I'm trying to send an email with a pdf attachment but the file comes embeded in email body on this form :

+212 319 9200 --mimepart_4610c204ab1b1_309b..fdbf7a3ea954 Content-Type: multipart/mixed; boundary=mimepart_4610c204ab4f8_309b..fdbf7a3ea105d --mimepart_4610c204ab4f8_309b..fdbf7a3ea105d Content-Type: application/pdf; charset=utf-8 Content-Transfer-Encoding: Base64 Content-Disposition: inline JVBERi0xLjMKMyAwIG9iago8PC9UeXBlIC9QYWdlCi9QYXJlbnQgMSAwIFIK L1Jlc291cmNlcyAyIDAgUgovQW5ub3RzIFs8PC9UeXBlIC9Bbm5vdCAvU3ViEtc..

this my configuration:
# CONFIGURATION ActionMailer
ActionMailer::Base.delivery_method = :sendmail  
ActionMailer::Base.perform_deliveries = true  
ActionMailer::Base.raise_delivery_errors = true  
ActionMailer::Base.default_charset = "utf-8"

and this is my model
part 'multipart/mixed' do |p|
     p.content_type='text/html'
     p.part :content_type => "application/pdf",
     :content_disposition => 'inline',
     :body => File.read(RAILS_ROOT + "/public/images/pdf/07032701s.pdf"),
     :filename => File.read(RAILS_ROOT + "/public/images/pdf/07032701s.pdf"),
     :transfer_encoding => "Base64",
     :charset => "utf-8"

Does anyone have a simple solution to this problem?

Thanks in advance,

2007-04-02 03:52 AM

Hi there - are you sure the :filename=> should be a File.read ?  

see
http://wiki.rubyonrails.org/rails/pages/HowToSendEmailsWithActionMailer

I think it should be

:filename => "public/images/pdf/07032701s.pdf"   -- or something like that...

2007-04-02 08:32 AM


Hello Guest! In order to post you must be an active client with us, please log in or sign up today!