我在这里研究了很多问题和答案,从我可以看到我的代码是正确的。 由于某些原因,我选择的邮件没有被删除。
我的代码是:
m = imaplib.IMAP4_SSL("imap-mail.outlook.com") m.login("MY_EMAIL","MY_PWORD") m.select("Sent") resp, data = m.uid("search", None, "ALL") uid = data[0].split()[-1] #Can also get message content with lines # resp,data = m.uid('fetch',uid,"(BODY[HEADER])") # print(data) m.store(uid, "+FLAGS", "\\Deleted") #Works fine to here m.expunge() #This doesn't delete message m.close() m.logout()如果我将m.expunge()行更改为print(m.expunge()) ,则获取元组
('确定',[无])
即使“OK”响应,该消息仍在邮箱中。 我不确定为什么会发生这种情况
I have studied numerous questions and answers here and from what I can see my code is correct. For some reason though, the mail I have selected is not being deleted.
My code is:
m = imaplib.IMAP4_SSL("imap-mail.outlook.com") m.login("MY_EMAIL","MY_PWORD") m.select("Sent") resp, data = m.uid("search", None, "ALL") uid = data[0].split()[-1] #Can also get message content with lines # resp,data = m.uid('fetch',uid,"(BODY[HEADER])") # print(data) m.store(uid, "+FLAGS", "\\Deleted") #Works fine to here m.expunge() #This doesn't delete message m.close() m.logout()If I change the m.expunge() line to print(m.expunge()) I get the tuple
('OK', [None])
The message is still in the mailbox even with the "OK" response. I'm unsure why this happens
最满意答案
您正在使用UID标识邮件,因此您还需要使用UID命令来更改\ Deleted标志:
m.uid('STORE' uid, "+FLAGS", "\\Deleted")您当前正在尝试使用相同的UID(可能不存在)设置消息序列号上的已删除标志,或者指向完全不同的消息。
You are using UIDs to identify the messages, so you also need to use UID commands to change the \Deleted flag:
m.uid('STORE' uid, "+FLAGS", "\\Deleted")You are currently trying to set the deleted flag on Message Sequence Number with the same UID, which probably doesn't exist, or refers to a completely different message.
更多推荐
发布评论