I am trying to search for messages in the Sent (actually i care for both) but I only get incoming messages. For the time being i have
imap_conn.select()
str_after = after.strftime('%d-%b-%Y')
typ, msg_ids = imap_conn.search('UTF-8','SINCE',str_after)
Which gives equivalent results with this
imap_conn.select('INBOX')
When I replace INBOX with ALL or SENT I get: command SEARCH illegal in state AUTH, only allowed in states SELECTED
Man, the error message is so misleading. What it's really saying is that you have tried to select an invalid folder name hence the search operation fails.
To verify/check the current valid folders/labels do something like:
Using ImapClient
Using imaplib
After I could see what folder names it was expecting, all was well.
Make sure you use the extra quotes in your string:
That worked for me.
Need to use print
imap_conn.list()
. Tags are language based. for example in spanish is[Gmail]/Todos
You need to use: imap_conn.select('[Gmail]/Sent Mail')
Just wanted to point this out for future users who see this. It's hidden in the comments.