# Best way to extract data from emails?

**URL:** <https://www.ruby-forum.com/t/best-way-to-extract-data-from-emails/101435>\
**Category:** Engines\
**Created:** [February 6, 2006, 2:26am UTC](https://www.ruby-forum.com/t/best-way-to-extract-data-from-emails/101435 "2006-02-06T02:26:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![generik](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/4da419/32.png) [@generik](https://www.ruby-forum.com/u/generik)\
**Post date:** [February 6, 2006, 2:26am UTC](https://www.ruby-forum.com/t/best-way-to-extract-data-from-emails/101435/1 "2006-02-06T02:26:37Z")

</div>

Hi,

I’ve been working on something that would look at a form mail, and then  
extract information out of that mail into ruby usable form.

For instance, let’s say someone sends you an email through eBay’s form  
mail facility, but her message body is encapsulated in all that nice and  
fancy HTML, so what I’d like to do is to hack up something that can read  
in this email, and just get at the message body less the extra  
formatting.

What’d be the best way to go about doing it?

I know it can be done with regular expressions, but ideally I want to  
make this a solution that can be easily updated as the format of the  
emails change, so regular expressions might not be able to give that  
flexibility.

Any tips welcome! 🙂

Thanks.

---

<div class="post-metadata">

**Author:** ![generik](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/4da419/32.png) [@generik](https://www.ruby-forum.com/u/generik)\
**Post date:** [February 7, 2006, 1:40pm UTC](https://www.ruby-forum.com/t/best-way-to-extract-data-from-emails/101435/2 "2006-02-07T13:40:58Z")

</div>

You might get more response to this on the rails list itself, since  
it’s not engine-specific…

- james

On 2/6/06, Woei S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> –  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
> 
> * * *
> 
> engine-users mailing list  
> removed\_email\_address@domain.invalid  
> [http://lists.rails-engines.org/listinfo.cgi/engine-users-rails-engines.org](http://lists.rails-engines.org/listinfo.cgi/engine-users-rails-engines.org)

–

- J \*  
~

---

<div class="post-metadata">

**Author:** ![generik](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/4da419/32.png) [@generik](https://www.ruby-forum.com/u/generik)\
**Post date:** [May 5, 2006, 10:20pm UTC](https://www.ruby-forum.com/t/best-way-to-extract-data-from-emails/101435/3 "2006-05-05T22:20:45Z")

</div>

> in this email, and just get at the message body less the extra  
> formatting.

I once did this by piping the message-body through a console-based  
browser such as w3m… Seems pretty fail-safe and easy…

Wybo
