Generate PDF and attach to email on the fly

Hi Friends!

I have a controller action that can render the response in pdf format as
well as html format.

Now, I need to attach a pdf file rendered by the above action to an
email on the fly.
How can I do this?
What is the the best practice?

Many thanks!!!

Rails L. wrote:

Hi Friends!

I have a controller action that can render the response in pdf format as
well as html format.

Now, I need to attach a pdf file rendered by the above action to an
email on the fly.
How can I do this?
What is the the best practice?

Not everything has an official “best practice”. But if I were you, I
wouldn’t do this. I don’t like getting large attachments. What I
recommend instead is to send an e-mail message with the URL for the
generated PDF file.

Many thanks!!!

Thanks Everybody!

I have figure out myself how to do this.
I just passed the binary data of the PDF to the mailer and then create
the attachment.

Thanks again!

Marnen Laibow-Koser wrote:

wouldn’t do this. I don’t like getting large attachments. What I
recommend instead is to send an e-mail message with the URL for the
generated PDF file.

+1 for that idea from me too. Not everyone reads mail in a “webmail”
environment. If you pull your email on a small phone this is
especially painful. The URL scheme let’s the user choose.

Bob