Attachment issue

Hi,

I generated the pdf file with image header (jpg log is displayed on top
of the pdf file). I can see the logo and the datas in the pdf file
generated. Fine. I tried to send the generated pdf in the email (using
action mailer). Iam getting the pdf file in the email, but when I open
the pdf file, the acrobat reader is not able to open the file.

The problem here is the action mailer is not sending the pdf file
properly if the pdf has image inside.

This is the code:

attachment "application/pdf" do |a|
        a.body = File.read(email_attachment)
        puts "FIle name"
        puts File.basename(email_attachment)
        a.filename=File.basename(email_attachment)
end

Any idea to fix the issue?

Fixed the issue

email_attachment = "#{RAILS_ROOT}/public/#{file_name}"

      attachment "application/pdf" do |a|
        file = File.new(email_attachment, "r+b")
        a.body = file.read
        a.filename=file_name
      end