# Actionmailer whoes

**URL:** <https://www.ruby-forum.com/t/actionmailer-whoes/172924>\
**Category:** Rails\
**Created:** [July 30, 2009, 1:24am UTC](https://www.ruby-forum.com/t/actionmailer-whoes/172924 "2009-07-30T01:24:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dandiebolt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/a87d85/32.png) [@dandiebolt](https://www.ruby-forum.com/u/dandiebolt)\
**Post date:** [July 30, 2009, 1:24am UTC](https://www.ruby-forum.com/t/actionmailer-whoes/172924/1 "2009-07-30T01:24:17Z")

</div>

Im pulling some emails off of a server, parsing them with TMail and  
looping through them in the view and displaying them. My problem is  
that I want to display the html emails I have but when I put them on the  
page the and tags of the email Im importing are being  
injected into my sites html and body tags, which leads to some extremely  
weird results. If I escape the html via h @mail.body\_html, I of course  
get a garbled mess. Any ideas on how to cut out these tags properly?

---

<div class="post-metadata">

**Author:** ![dandiebolt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/a87d85/32.png) [@dandiebolt](https://www.ruby-forum.com/u/dandiebolt)\
**Post date:** [July 30, 2009, 2:51am UTC](https://www.ruby-forum.com/t/actionmailer-whoes/172924/2 "2009-07-30T02:51:42Z")

</div>

On Wed, Jul 29, 2009 at 4:24 PM, Dan  
Dunn[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Im pulling some emails off of a server, parsing them with TMail and  
> looping through them in the view and displaying them. My problem is  
> that I want to display the html emails I have but when I put them on the  
> page the and tags of the email Im importing are being  
> injected into my sites html and body tags, which leads to some extremely  
> weird results. If I escape the html via h @mail.body\_html, I of course  
> get a garbled mess. Any ideas on how to cut out these tags properly?

Use something like hpricot to (short version) get the innerHTML of  
the BODY element of the email.

The doc/examples are pretty straightforward, but post back if you  
have problems with it.

## HTH,

Hassan S. ------------------------ removed\_email\_address@domain.invalid  
twitter: @hassan
