我试图在
Ruby中使用Net :: IMAP来搜索我发送的所有邮件,但是我无法选择INBox以外的任何东西.
imap.select('INBox')
工作正常,但
imap.select('Mail/sent-mail')
如Net :: IMAP文档中所示,给我“未知的邮箱”.
顺便说一句,这是用于gmail.
我也尝试在我的imap.search()中添加“in”,“anywhere”,但没有解析.
当前代码:
imap.select('INBox') now = Time.now.localtime - 1209600 #two weeks since = now.day.to_s() + "-" + Date::MONTHNAMES[now.month] + "-" + now.year.to_s() puts "since" puts since begin mail_ids = imap.search(["FROM","me","SINCE",since]) mail_ids.each do |id| text = imap.fetch(id,'BODY[HEADER.FIELDS (SUBJECT)]').to_s.split("{").second.chop puts text end end