I am trying to parse an email that I receive in html format. http://pastie.textmate.org/265259 I am looking through http://tmail.rubyforge.org to see how this works but am not having much luck with the Quick Start examples. email = TMail::Mail.load( ''emailhtml.eml'' ) => #<TMail::Mail port=#<TMail::FilePort:/emailhtml.eml> bodyport=nil> >> puts email.to nil => nil Any help would be appreciated as I''m sorta stuck. Thanks, Geo
On Thu, Sep 4, 2008 at 1:28 AM, George Cooper <geocooper at gmail.com> wrote:> I am looking through http://tmail.rubyforge.org to see how this works but am > not having much luck with the Quick Start examples. > > email = TMail::Mail.load( ''emailhtml.eml'' ) > => #<TMail::Mail port=#<TMail::FilePort:/emailhtml.eml> bodyport=nil> >>> puts email.to > nil > => nil > > Any help would be appreciated as I''m sorta stuck.What do you get if you do email.to_s ? Wondering if it is parsing correctly. You can also try email[''to''] -- http://lindsaar.net/ Rails, RSpec and Life blog....
On Sep 6, 2008, at 1:17 AM, Mikel Lindsaar wrote:>> email = TMail::Mail.load( ''emailhtml.eml'' ) >> => #<TMail::Mail port=#<TMail::FilePort:/emailhtml.eml> bodyport=nil> >>>> puts email.to >> nil >> => nil >> >> Any help would be appreciated as I''m sorta stuck. > > What do you get if you do email.to_s ?I get Nil back> > > Wondering if it is parsing correctly. > > You can also try email[''to'']This also returns Nil Here is the code I am using and below are the results: require ''rubygems'' require ''tmail'' email = TMail::Mail.load( ''emailhtml.eml'' ) puts email.to_s # returns entire email puts email[''body''] # comes back nil puts email[''from''] puts email[''Delivered-To''] puts email[''to''] # comes back nil puts email[''subject''] puts email[''date''] puts email[''X-Originalarrivaltime''] Results (excluding entire email) nil user2 at sender2.com geocooper at 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] -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/tmail-talk/attachments/20080908/6d3df7e7/attachment.html>