Forum: Ruby on Rails Generate PDF and attach to email on the fly

Posted by Rails Learner (railslearner)
on 2010-07-09 18:20
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!!!!!
Posted by Marnen Laibow-Koser (marnen)
on 2010-07-10 15:46
Rails Learner 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!!!!!
Posted by Bob Proulx (Guest)
on 2010-07-10 22:27
(Received via mailing list)
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
Posted by Rails Learner (railslearner)
on 2010-07-10 23:30
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!
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.