[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

IMAP, Gmail & reading the body of the message

Azalar ---

9/3/2008 3:29:00 PM

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-....

5 Answers

Luis Parravicini

9/4/2008 8:07:00 AM

0

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.ht...
) 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.ruby... ) to parse the
mail after getting it.


--
Luis Parravicini
http://ktulu.co...

Azalar ---

9/4/2008 9:21:00 AM

0

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://ww...\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-....

Charles A Gray

9/4/2008 11:52:00 AM

0

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.ht...
> ) 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.ruby... ) to parse the
> mail after getting it.
>
>
gmail is pop3 with ssl encoding.


Azalar ---

9/4/2008 12:05:00 PM

0

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-....

Mark Firestone

9/4/2008 3:00:00 PM

0

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.ht...
>> ) 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.ruby... ) 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.