Pdf attachment to be in the same name

Hi

I am sending email with pdf attachment using ActionMailer. But when I am
receiving it, it is received in a different file name like ATT00319.pdf
I wanted to receive the attachment with original file name.

Thanks in advance.

Vidya, the fix for this issue is you need to put r+b when creating the
file.

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