Forum: Ruby on Rails Attaching files to emails using ActionMailer

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Stewart (Guest)
on 2009-05-21 04:48
(Received via mailing list)
Hey Guys,

I wish to generate a PDF on the fly to attach to an email.  I am using
action mailer and I want to tell the action mailer to attach a PDF
from a URL not a file.  All of the examples I have seen attach the
file to the email like so...

      attachment :content_type => "image/jpeg",
        :body =>"an-image.jpg")

Is there anyway I can make it so that "an-image.jpg" is called from a
url on the localhost so something like "localhost/invoice.pdf".  This
will fit in to my rails app as it generates a PDF using prawn and
prawnto from that url.

Thanks for any help
pharrington (Guest)
on 2009-05-21 05:02
(Received via mailing list)
didn't try this myself, but use open-uri?

      attachment :content_type => "image/jpeg",
        :body => open("").read
This topic is locked and can not be replied to.