Last active
April 29, 2016 07:28
-
-
Save yalab/8690e834cc5fbc791e123fd0c85a8cf3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'net/imap' | |
imap = Net::IMAP.new('imap.gmail.com', 993, true) | |
imap.login(ENV["GMAIL_USER"], ENV["GMAIL_PASSWORD"]) | |
imap.select("Inbox") | |
listprefix = "[Imap]/" | |
listname = "PROCESSED" | |
unless imap.list(listprefix, listname) | |
imap.create("#{listprefix}#{listname}") | |
end | |
ids = imap.search(["SINCE", "1-Apr-2000"]) | |
while id = ids.pop | |
response = imap.copy(id, "#{listprefix}#{listname}") | |
unless response.data.code | |
ids.push(id) | |
next | |
end | |
imap.store(id, "+FLAGS", [:Deleted]) | |
end | |
imap.expunge |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
上手くいっている response
#<struct Net::IMAP::TaggedResponse tag="RUBY0009", name="OK", data=#<struct Net::IMAP::ResponseText code=#<struct Net::IMAP::ResponseCode name="COPYUID", data="56 8 13">, text=" (Success)">, raw_data="RUBY0009 OK [COPYUID 56 8 13] (Success)\r\n">
うまくいっていない response
#<struct Net::IMAP::TaggedResponse tag="RUBY0011", name="OK", data=#<struct Net::IMAP::ResponseText code=nil, text="Success">, raw_data="RUBY0011 OK Success\r\n">