Eric Hodel
8/11/2008 10:10:00 PM
On Aug 11, 2008, at 09:27 AM, Junkone wrote:
> how do i extract the message body using imap. i am hunting it and
> cannot seem to figure it out. probably i am not sure what the specific
> envelope attribute it should be. i tried envelope.body but it does not
> like it.
>
> imap = Net::IMAP.new('imap.gmail.com','993',true)
> imap.login(username, password)
> imap.select('INBOX')
>
> imap.search(["NOT", "DELETED" ).each do |message_id|
> envelope = imap.fetch(message_id, "ENVELOPE")[0].attr["ENVELOPE"]
> puts "#{envelope.from[0].name}: \t#{envelope.subject}"
> # imap.store(message_id, "+FLAGS", [:Deleted])
> end
>
> imap.logout()
> imap.disconnect()
See RFC 3501 section 6.4.5. You probably want BODY[] judging from
your example code.