# Composing HTML e-mail with a PDF attachment

**URL:** <https://www.ruby-forum.com/t/composing-html-e-mail-with-a-pdf-attachment/50492>\
**Category:** Rails\
**Created:** [December 16, 2005, 11:06pm UTC](https://www.ruby-forum.com/t/composing-html-e-mail-with-a-pdf-attachment/50492 "2005-12-16T23:06:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Reuven\_MSLerner](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/6de8d8/32.png) [@Reuven\_MSLerner](https://www.ruby-forum.com/u/Reuven_MSLerner)\
**Post date:** [December 16, 2005, 11:06pm UTC](https://www.ruby-forum.com/t/composing-html-e-mail-with-a-pdf-attachment/50492/1 "2005-12-16T23:06:39Z")

</div>

Hi, everyone. I’ve been using Rails for a little while now, and am  
really, really enjoying the experience.

I’m having the darndest time trying to send e-mail whose contents are in  
HTML, and which includes a PDF attachment. Following various  
instructions (in the Pragmatic book, as well as at  
[http://wiki.rubyonrails.com/rails/pages/HowToSendEmailsWithActionMailer](http://wiki.rubyonrails.com/rails/pages/HowToSendEmailsWithActionMailer)),  
I’m able to send HTML e-mail _or_ a PDF attachment (generated from  
pdf/writer). But I can’t figure out how to use an .rhtml template to  
generate the HTML, and then attach a PDF file to it. I’ve thought about  
rendering a separate template from the one with the same name as my  
ActionMailer subclass, but it seems a bit roundabout to define two  
different methods to send one e-mail message.

I’ve tried the suggestions at  
[http://wiki.rubyonrails.com/rails/pages/HowToSendMimeMultipartEmailsWithActionMailer](http://wiki.rubyonrails.com/rails/pages/HowToSendMimeMultipartEmailsWithActionMailer),  
but to no avail.

Does anyone have a simple solution to this problem?

Thanks in advance,

Reuven

---

<div class="post-metadata">

**Author:** ![Reuven\_MSLerner](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/6de8d8/32.png) [@Reuven\_MSLerner](https://www.ruby-forum.com/u/Reuven_MSLerner)\
**Post date:** [December 18, 2005, 5:25pm UTC](https://www.ruby-forum.com/t/composing-html-e-mail-with-a-pdf-attachment/50492/2 "2005-12-18T17:25:18Z")

</div>

Hi Reuven,  
which way do you send the email? Using the raw TMail object as described  
in the HowToSendMimeMultipartEmailsWithActionMailer? Can you post some  
code?

Thanks

Peter
