Guest User

Untitled

a guest
Mar 9th, 2018
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. require 'net/imap'
  2. require 'pp'
  3.  
  4. USERNAME = 'uname'
  5. PASSWORD = 'pword'
  6.  
  7. imap = Net::IMAP.new('imap.gmail.com',993,true)
  8. imap.login(USERNAME,PASSWORD)
  9. imap.examine('INBOX')
  10. msgs = imap.search(["UNSEEN"]).map do |message_id|
  11. envelope = imap.fetch(message_id, "ENVELOPE")[0].attr["ENVELOPE"]
  12. [envelope.from[0].name,envelope.subject]
  13. end
  14.  
  15. pp msgs
Add Comment
Please, Sign In to add comment