# How to capture generated HTML and sending it in e-mail

**URL:** <https://www.ruby-forum.com/t/how-to-capture-generated-html-and-sending-it-in-e-mail/151249>\
**Category:** Rails\
**Created:** [October 18, 2008, 9:13pm UTC](https://www.ruby-forum.com/t/how-to-capture-generated-html-and-sending-it-in-e-mail/151249 "2008-10-18T21:13:29Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tadatoshi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e9bcb4/32.png) [@tadatoshi](https://www.ruby-forum.com/u/tadatoshi)\
**Post date:** [October 18, 2008, 9:13pm UTC](https://www.ruby-forum.com/t/how-to-capture-generated-html-and-sending-it-in-e-mail/151249/1 "2008-10-18T21:13:29Z")

</div>

Hi,

Is there a way to capture the generated HTML (e.g. for show.html.erb)  
from inside a Rails application?

I need to send an e-mail to users with the same HTML as displayed on  
the browser.

Thank you in advance.

Tadatoshi

---

<div class="post-metadata">

**Author:** ![tadatoshi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e9bcb4/32.png) [@tadatoshi](https://www.ruby-forum.com/u/tadatoshi)\
**Post date:** [October 19, 2008, 3:36am UTC](https://www.ruby-forum.com/t/how-to-capture-generated-html-and-sending-it-in-e-mail/151249/2 "2008-10-19T03:36:46Z")

</div>

Tadatoshi T. wrote:

> Is there a way to capture the generated HTML (e.g. for show.html.erb)  
> from inside a Rails application?

Have a look at render\_to\_string.

Peace.

---

<div class="post-metadata">

**Author:** ![tadatoshi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e9bcb4/32.png) [@tadatoshi](https://www.ruby-forum.com/u/tadatoshi)\
**Post date:** [October 19, 2008, 5:00am UTC](https://www.ruby-forum.com/t/how-to-capture-generated-html-and-sending-it-in-e-mail/151249/3 "2008-10-19T05:00:42Z")

</div>

Thank you, Phillip.

I will try that.

Sincerely,  
Tadatoshi

On Oct 18, 9:36 pm, Phillip K. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![tadatoshi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e9bcb4/32.png) [@tadatoshi](https://www.ruby-forum.com/u/tadatoshi)\
**Post date:** [October 28, 2008, 1:13am UTC](https://www.ruby-forum.com/t/how-to-capture-generated-html-and-sending-it-in-e-mail/151249/4 "2008-10-28T01:13:05Z")

</div>

Hi, Phillip,

render\_to\_string worked very well.

Thank you for your help.

Sincerely,  
Tadatoshi

On Oct 18, 10:59 pm, tadatoshi [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
