I''m resending this because I don''t see it showing up on the list and also including a link to the actual email I''m trying to parse. The email is here: http://pastie.org/265259 I also posed my issue to the ruby-forum list and was direct back to this list. http://www.ruby-forum.com/topic/164757 I really am not sure what I am doing wrong. Is it because the body of the email does not start with ''body'' like when extracting the ''from'' for example. thanks for any help with this.> > > 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[''subject''] puts email[''date''] puts email[''X-Originalarrivaltime''] Results (excluding entire email) nil user2 at sender2.com geocooper at gmail.com [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] On Sep 6, 2008, at 1:17 AM, Mikel Lindsaar wrote:> 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.... > _______________________________________________ > Tmail-talk mailing list > Tmail-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/tmail-talk
Peter Burkholder
2008-Sep-10 18:45 UTC
[Tmail-talk] where to start with this parse request
Hi George, I''m not quite sure what your question is here. email.body returns the body email[''to''] is Nil because there''s no ''To: '' header email[''delivered-to''].to_s might help (ah, but I see you already know that). Cheers, Peter On Sep 10, 2008, at 1:31 PM, George Cooper wrote:> 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[''subject''] > puts email[''date''] > puts email[''X-Originalarrivaltime''] > > Results (excluding entire email) > nil > user2 at sender2.com > geocooper at gmail.com > [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]-- Peter Burkholder [Contractor] +1-301-402-7499 burkholp at ncbi.nlm.nih.gov Applications Administrator, NCBI/NLM/NIH
Peter, Okay, now I feel pretty silly because yes email.body works perfectly. I''m still not sure why email[''body''] doesn''t though. I am very new to ruby and programming in general, so I apologize my lack of knowledge on this. Now I can keep moving forward. Thanks so much, On Sep 10, 2008, at 2:45 PM, Peter Burkholder wrote:> Hi George, > > I''m not quite sure what your question is here. > > email.body returns the body > > email[''to''] is Nil because there''s no ''To: '' header > > email[''delivered-to''].to_s might help (ah, but I see you already > know that). > > Cheers, > > Peter > > > On Sep 10, 2008, at 1:31 PM, George Cooper wrote: > >> 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[''subject''] >> puts email[''date''] >> puts email[''X-Originalarrivaltime''] >> >> Results (excluding entire email) >> nil >> user2 at sender2.com >> geocooper at gmail.com >> [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] > > -- > Peter Burkholder [Contractor] > +1-301-402-7499 burkholp at ncbi.nlm.nih.gov > Applications Administrator, NCBI/NLM/NIH > > > > > _______________________________________________ > Tmail-talk mailing list > Tmail-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/tmail-talk
Peter Burkholder
2008-Sep-10 20:50 UTC
[Tmail-talk] where to start with this parse request
On Sep 10, 2008, at 4:13 PM, George Cooper wrote:> Okay, now I feel pretty silly because yes email.body works > perfectly. I''m still not sure why email[''body''] doesn''t though.The hash methods of TMail::Mail object only work for the headers. Try email.keys> > > I am very new to ruby and programming in general, so I apologize my > lack of knowledge on this.At least you had the guts to ask. Cheers, Peter -- Peter Burkholder [Contractor] +1-301-402-7499 burkholp at ncbi.nlm.nih.gov Applications Administrator, NCBI/NLM/NIH