From geocooper at gmail.com Wed Sep 3 11:28:56 2008 From: geocooper at gmail.com (George Cooper) Date: Wed, 3 Sep 2008 11:28:56 -0400 Subject: [Tmail-talk] where to start with this parse request Message-ID: 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' ) => # bodyport=nil> >> puts email.to nil => nil Any help would be appreciated as I'm sorta stuck. Thanks, Geo From raasdnil at gmail.com Sat Sep 6 01:17:36 2008 From: raasdnil at gmail.com (Mikel Lindsaar) Date: Sat, 6 Sep 2008 15:17:36 +1000 Subject: [Tmail-talk] where to start with this parse request In-Reply-To: References: Message-ID: <57a815bf0809052217y48698a7etafdbda435d8486@mail.gmail.com> On Thu, Sep 4, 2008 at 1:28 AM, George Cooper 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' ) > => # 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.... From geocooper at gmail.com Mon Sep 8 10:25:11 2008 From: geocooper at gmail.com (George Cooper) Date: Mon, 8 Sep 2008 10:25:11 -0400 Subject: [Tmail-talk] where to start with this parse request In-Reply-To: <57a815bf0809052217y48698a7etafdbda435d8486@mail.gmail.com> References: <57a815bf0809052217y48698a7etafdbda435d8486@mail.gmail.com> Message-ID: On Sep 6, 2008, at 1:17 AM, Mikel Lindsaar wrote: >> email = TMail::Mail.load( '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: From burkholp at ncbi.nlm.nih.gov Tue Sep 9 14:52:32 2008 From: burkholp at ncbi.nlm.nih.gov (Peter Burkholder) Date: Tue, 9 Sep 2008 14:52:32 -0400 Subject: [Tmail-talk] Parsing complex mail messages Message-ID: <7E7B4F15-44EF-408C-8A4F-8361B1B68657@ncbi.nlm.nih.gov> Hi, I'm working on writing an inboound TMail gateway to a web application. So far I've been very pleased with TMail's capabilities and ease of use. Thanks! One of the challenges I'm looking at is handling messages with attachments, such as images or documents. For example, the quoted message below from Apple's Mail.app has two inline images separating three parts of text. The overall structure is: =========== Hi I'm having some trouble with this image: [image] and I want it look like this: [image] -- Signature =========== It there a good way to pull out the message text (in three parts) from the included attachments without my having to read all of RFCs 2045,2046. Other message compositions I've seen are: multipart/mixed( multipart/ alternative (text/plain, text/html)), attachment). And so on. I guess I could do a join of all the parts that are text/plain (unless they're attachments or inline) to make the message body. But I suspect that someone has done all this before and I'm loathe to reinvent the wheel (esp. since I doubt mine would roll too well). So, to recap, does anyone have any code to suggest that would help pull apart multipart messages into the 'message content' and associate attachments/inline parts? Thanks, Peter > To: Peter Burkholder > Content-Type: multipart/mixed; boundary=Apple-Mail-4-3849828 > Mime-Version: 1.0 (Apple Message framework v926) > Subject: Another test > Date: Tue, 9 Sep 2008 12:11:41 -0400 > X-Mailer: Apple Mail (2.926) > Return-Path: burkholp at .gov > > > --Apple-Mail-4-3849828 > Content-Type: text/plain; > charset=US-ASCII; > format=flowed > Content-Transfer-Encoding: 7bit > > Hi I'm having some trouble with this image: > > > --Apple-Mail-4-3849828 > Content-Disposition: inline; > filename=left.GIF > Content-Type: image/gif; > x-unix-mode=0644; > name="left.GIF" > Content-Transfer-Encoding: base64 > > R0lGODlhggAtAMT/AP////L1+fH1+OXs8uXr8tni7Nji68zZ5cjW47/ > P37vM3bLF2a3C1qW80qG4 > 0JmzzJGsyI2pxoSjwYCgv3eZu3OWuWmPtGaMs1mDrE15pkBwnzNmmQAAAAAAAAAAAAAAACwAAAAA > [snip] > YKHg > + > FtXlgkyKCZ3OTepC3ywaRg1lq2WBAPSYAABeSQgYeI01aR6pyNc5lDBpjaA2UyBIiDlZlSn > DUKMEr8Eg8B1xeBq3rHIJqssaSEAADuz0LoQAgA7VmvtBLW0hAAAOw== > > --Apple-Mail-4-3849828 > Content-Type: text/plain; > charset=US-ASCII; > format=flowed > Content-Transfer-Encoding: 7bit > > > > > and I want it to look like this: > > --Apple-Mail-4-3849828 > Content-Disposition: inline; > filename=left.GIF > Content-Type: image/gif; > x-unix-mode=0644; > name="left.GIF" > Content-Transfer-Encoding: base64 > > R0lGODlhggAtAMT/AP////L1+fH1+OXs8uXr8tni7Nji68zZ5cjW47/ > P37vM3bLF2a3C1qW80qG4 > 0JmzzJGsyI2pxoSjwYCgv3eZu3OWuWmPtGaMs1mDrE15pkBwnzNmmQAAAAAAAAAAAAAAACwAAAAA > [snip] > YKHg > + > FtXlgkyKCZ3OTepC3ywaRg1lq2WBAPSYAABeSQgYeI01aR6pyNc5lDBpjaA2UyBIiDlZlSn > DUKMEr8Eg8B1xeBq3rHIJqssaSEAADuz0LoQAgA7VmvtBLW0hAAAOw== > > --Apple-Mail-4-3849828 > Content-Type: text/plain; > charset=US-ASCII; > format=flowed; > delsp=yes > Content-Transfer-Encoding: 7bit > > > > -- > Peter Burkholder [Contractor] > +1-301-402-7499 burkholp at .gov > Applications Administrator, NCBI/NLM/NIH > > > > > > --Apple-Mail-4-3849828-- From geocooper at gmail.com Wed Sep 10 13:31:20 2008 From: geocooper at gmail.com (George Cooper) Date: Wed, 10 Sep 2008 13:31:20 -0400 Subject: [Tmail-talk] where to start with this parse request Message-ID: 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 > 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' ) >> => # 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 From burkholp at ncbi.nlm.nih.gov Wed Sep 10 14:45:58 2008 From: burkholp at ncbi.nlm.nih.gov (Peter Burkholder) Date: Wed, 10 Sep 2008 14:45:58 -0400 Subject: [Tmail-talk] where to start with this parse request In-Reply-To: References: Message-ID: 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 From geocooper at gmail.com Wed Sep 10 16:13:27 2008 From: geocooper at gmail.com (George Cooper) Date: Wed, 10 Sep 2008 16:13:27 -0400 Subject: [Tmail-talk] where to start with this parse request In-Reply-To: References: Message-ID: <1917D3AE-6DE8-4BE3-A36D-987D073465FC@gmail.com> 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 From burkholp at ncbi.nlm.nih.gov Wed Sep 10 16:50:02 2008 From: burkholp at ncbi.nlm.nih.gov (Peter Burkholder) Date: Wed, 10 Sep 2008 16:50:02 -0400 Subject: [Tmail-talk] where to start with this parse request In-Reply-To: <1917D3AE-6DE8-4BE3-A36D-987D073465FC@gmail.com> References: <1917D3AE-6DE8-4BE3-A36D-987D073465FC@gmail.com> Message-ID: <7F6CA6E6-E842-489E-A3DB-62FF07688162@ncbi.nlm.nih.gov> 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 From zeljko.filipin at gmail.com Tue Sep 23 10:22:34 2008 From: zeljko.filipin at gmail.com (=?UTF-8?Q?=C5=BDeljko_Filipin?=) Date: Tue, 23 Sep 2008 16:22:34 +0200 Subject: [Tmail-talk] broken link at tmail.rubyforge.org Message-ID: Hi, I found a broken link at tmail.rubyforge.org. "User Manual - needs updating" leads to http://tmail.rubyforge.org/manual/index.html that returns 404 Not Found. ?eljko Filipin -- ZeljkoFilipin.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From raasdnil at gmail.com Tue Sep 23 12:20:53 2008 From: raasdnil at gmail.com (Mikel Lindsaar) Date: Wed, 24 Sep 2008 02:20:53 +1000 Subject: [Tmail-talk] broken link at tmail.rubyforge.org In-Reply-To: References: Message-ID: <57a815bf0809230920u18af1ecdt6d7b8839a7d220f3@mail.gmail.com> Thanks... I'll look at it on the next update. Mikel On Wed, Sep 24, 2008 at 12:22 AM, ?eljko Filipin wrote: > Hi, > > I found a broken link at tmail.rubyforge.org. "User Manual - needs updating" > leads to http://tmail.rubyforge.org/manual/index.html that returns 404 Not > Found. > > ?eljko Filipin > -- > ZeljkoFilipin.com > > _______________________________________________ > Tmail-talk mailing list > Tmail-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/tmail-talk > > -- http://lindsaar.net/ Rails, RSpec and Life blog....