Mark All Unread Mail As Read In Ruby
Join the DZone community and get the full member experience.
Join For FreeThe following script will mark all of your unread mail as read in Ruby
require 'net/imap'
server = 'imap.mail.com'
username = 'YOUR USERNAME'
password = 'YOUR PASSWORD'
folder = 'INBOX'
imap = Net::IMAP.new(server, 993, true)
imap.login(user, password)
imap.select(folder)
imap.search(["NOT", "SEEN"]).each do |message_id|
imap.store(message_id, "+FLAGS", [:Seen])
end
imap.logout()
imap.disconnect()
Mail (Apple)
Mark (designation)
Opinions expressed by DZone contributors are their own.
Comments