在Python 3.4.3,如何使用IMAP协议发送flag 'Seen'

In Python 3.4.3, How to send flag 'Seen' with IMAP protocol

  1. 获取标记 'UNSEEN'
  2. 的邮件列表
  3. 阅读每封邮件
  4. 留个flag'Seen'我做的

我想在我的电子邮件帐户中设置邮件发送标志 'Seen'。 我如何在 python.

中设置 'Seen' 标志

你有什么想法吗?

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

我的错误信息是这样打印的

[DEBUG|imap.py:81]2017-02-24 21:43:57,921 > STORE command error: BAD [b'Error in IMAP command STORE: Invalid messageset'] 

您正在混合使用 UID 和序列集。

如果使用UID SEARCHUID FETCH,则需要使用UID STORE:

result = emailConnection.uid("STORE", uid, '+FLAGS', '\Seen')