IMAP, Gmail & reading the body of the message

I have been collecting emails to my Gmail account for some time from a
mailing list that I read and I want to write a Ruby script to iterate
through these messages and give me back the data in the body of the
message which I will then parse for the information I am looking for.
All of the examples I have seen while Googling for this show you how to
get headers but none of the sites showed how to read the body of the
message.
All the messages
Could someone explain how I can read my GMail messages via Ruby and IMAP
please?

···

--
Posted via http://www.ruby-forum.com/.

Hi

Use Net::IMAP.fetch (
http://www.ruby-doc.org/stdlib/libdoc/net/imap/rdoc/classes/Net/IMAP.html#M001284
) and using something like 'BODY[TEXT]' as the attributes argument to
fetch.
For example:

body = imap.fetch(msg.seqno, 'BODY[TEXT]')

Sometimes I use TMail ( http://tmail.rubyforge.org/ ) to parse the
mail after getting it.

···

On Wed, Sep 3, 2008 at 12:28 PM, Azalar --- <pteale@gmail.com> wrote:

All of the examples I have seen while Googling for this show you how to
get headers but none of the sites showed how to read the body of the
message.
All the messages
Could someone explain how I can read my GMail messages via Ruby and IMAP
please?

--
Luis Parravicini
http://ktulu.com.ar/blog/

This partially worked.
It gave me the info but had lots of crap around the actual text I am
trying to get at.
For instance, I got..

#<struct Net::IMAP::FetchData seqno=1,
attr={"BODY[TEXT]"=>"http://www.blah.com\r\n\r\n\r\n"}>

Where I just want the bit between the quotes.
I could parse what I have there and look for what is between the quotes
but is there a method on what is returned from ..

body = imap.fetch(message_id, 'BODY[TEXT]')

That gives just that text?

···

--
Posted via http://www.ruby-forum.com/.

gmail is pop3 with ssl encoding.

···

On Thu, 2008-09-04 at 17:07 +0900, Luis Parravicini wrote:

On Wed, Sep 3, 2008 at 12:28 PM, Azalar --- <pteale@gmail.com> wrote:
> All of the examples I have seen while Googling for this show you how to
> get headers but none of the sites showed how to read the body of the
> message.
> All the messages
> Could someone explain how I can read my GMail messages via Ruby and IMAP
> please?

Hi

Use Net::IMAP.fetch (
http://www.ruby-doc.org/stdlib/libdoc/net/imap/rdoc/classes/Net/IMAP.html#M001284
) and using something like 'BODY[TEXT]' as the attributes argument to
fetch.
For example:

body = imap.fetch(msg.seqno, 'BODY[TEXT]')

Sometimes I use TMail ( http://tmail.rubyforge.org/ ) to parse the
mail after getting it.

Charles Gray wrote:

···

On Thu, 2008-09-04 at 17:07 +0900, Luis Parravicini wrote:

Use Net::IMAP.fetch (

gmail is pop3 with ssl encoding.

Gmail also supports IMAP
--
Posted via http://www.ruby-forum.com/\.

Neat! I can connect the ruby BBS to Google Mail!

···

On Thu, Sep 4, 2008 at 12:51 PM, Charles Gray <smgspices@aol.com> wrote:

On Thu, 2008-09-04 at 17:07 +0900, Luis Parravicini wrote:

On Wed, Sep 3, 2008 at 12:28 PM, Azalar --- <pteale@gmail.com> wrote:
> All of the examples I have seen while Googling for this show you how to
> get headers but none of the sites showed how to read the body of the
> message.
> All the messages
> Could someone explain how I can read my GMail messages via Ruby and IMAP
> please?

Hi

Use Net::IMAP.fetch (
http://www.ruby-doc.org/stdlib/libdoc/net/imap/rdoc/classes/Net/IMAP.html#M001284
) and using something like 'BODY[TEXT]' as the attributes argument to
fetch.
For example:

body = imap.fetch(msg.seqno, 'BODY[TEXT]')

Sometimes I use TMail ( http://tmail.rubyforge.org/ ) to parse the
mail after getting it.

gmail is pop3 with ssl encoding.

--
Peter: I'll handle it, Lois. I read a book about this sort of thing once.

Brian: Are you sure it was a book? Are you sure it wasn't nothing?

Peter: Oh yeah.