消息没有用m.expunge删除(Message not deleting with m.expunge)

编程入门 行业动态 更新时间:2024-10-26 08:26:55
消息没有用m.expunge删除(Message not deleting with m.expunge)

我在这里研究了很多问题和答案,从我可以看到我的代码是正确的。 由于某些原因,我选择的邮件没有被删除。

我的代码是:

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.

更多推荐

本文发布于:2023-08-04 02:00:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1408859.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:消息   expunge   deleting   Message

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!