views:

103

answers:

1

Hello everyone, 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

A: 
import imaplib
obj = imaplib.IMAP4_SSL('imap.gmail.com',993)
obj.login('userid','password')
obj.select('Sent')  # <-- response like ('OK', ['74']) --> total no. of mail in sent folder
obj.uid('SEARCH',None,'All') # <-- Returns the list of uids of the sent folder.
Avadhesh
It did not work on Gmail for me so I used: imap_conn.select('[Gmail]/Sent Mail')
PanosJee
Avadhesh