From: Trans Date: 2008-09-09T07:13:18+09:00 Subject: Re: Extract data from email - Tmail, Hpricot On Sep 8, 11:31 am, Geo _C wrote: > Michael Morin wrote: > > George Cooper wrote: > >> I have tried Tmail, but can't seem to extract just the body.  Then I > >> tried Hpricot and wasn't sure what to use before the .inner_html. So > >> basically I'm very lost on where to start. > > >> Any help is appreciated. > > >> Thanks! > > > It would help if you posted some code that didn't work, so people can > > have a better idea of what you're trying to do.  Tmail should have been > > able to parse that without problem, however, extracting the body is > > easy.  The box follows the empty line.  You could use something like > > split, but duping such huge strings could be slow.  When you read the > > mail, try to read a line at a time until you get the empty line, then > > read the rest into a buffer for hpricot. > > Below is the code I am using to try and get the body out of the html > email (copy of emailhttp://pastie.org/265259) . > > require 'rubygems' > require 'tmail' > > email = TMail::Mail.load( 'emailhtml.eml' ) > > puts email['body'] # comes back nil Don't see why it would be nil. I would contact Mikel. http://lindsaar.net/ > puts email['from'] > puts email['Delivered-To'] > puts email['to'] # comes back nil I don't see a 'to' in the header, so is this a surprise? > puts email['subject'] > puts email['date'] > puts email['X-Originalarrivaltime'] > > results: > nil > us...@sender2.com > geocoo...@gmail.com > nil > [Freddy] New Incidents captured on 2008-09-02 > Tue, 2 Sep 2008 19:05:00 -0400 > 02 Sep 2008 23:10:35.0578 (UTC) FILETIME=[1B2659A0:01C90D51] T.