I'm trying to use Net::IMAP in Ruby to search all mail sent by me, but I'm having trouble selecting anything other than INBOX.
imap.select('INBOX')
works fine, but
imap.select('Mail/sent-mail')
as shown on the Net::IMAP documentation gives me "Unknown Mailbox".
Incidentally, this is to be used with gmail.
I also tried adding "in", "anywhere" to my imap.search(), but that didn't parse.
Current code:
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