I want to set a mail up flag 'Seen' in my email account. How can i set up 'Seen' Flag in python.
Do you have any idea?
import imaplib
emailConnection = imaplib.IMAP4_SSL()
emailConnection.login(id, password)
emailConnection.select(configData['email_input_folder'])
result, data = emailConnection.uid('SEARCH', None, '(UNSEEN)')
uids = data[0].split()
for uid in uids:
result, data = emailConnection.uid('fetch', uid, '(RFC822)')
# ------ data is manufactured.
result = emailConnection.store(uid, '+FLAGS', '\\Seen') # << Occured Exception
In My Error Message is printed like this.
[DEBUG|imap.py:81]2017-02-24 21:43:57,921 > STORE command error: BAD [b'Error in IMAP command STORE: Invalid messageset']
You're mixing UID and Sequence Sets.
If you use UID SEARCH
and UID FETCH
, you need to use UID STORE
:
result = emailConnection.uid("STORE", uid, '+FLAGS', '\\Seen')