gmail imap

J

Junkone

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()
 
E

Eric Hodel

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,754
Messages
2,569,527
Members
44,999
Latest member
MakersCBDGummiesReview

Latest Threads

Top