简体   繁体   English

移至Gmail存档-Python Imaplib

[英]Move to Gmail Archive - Python Imaplib

I'm trying to write a script which moves a particular email to Archive after getting its text, however I've looked all over the place and tried plenty of solutions. 我正在尝试编写一个脚本,将特定的电子邮件在收到文本后移至“存档”,但是我到处都是,并尝试了许多解决方案。 My understanding is that when a message is archived, all of its labels are removed and it only appears in the All Mail folder. 我的理解是,将邮件存档后,所有标签将被删除,并且仅显示在“所有邮件”文件夹中。

This is my current code to try to remove any labels associated with the message, I believe that this should archive the message, however it seems to do nothing. 这是我当前的尝试删除与邮件相关联的标签的当前代码,我相信这应该将邮件存档,但是它似乎无能为力。 There are no errors when running this code. 运行此代码时没有错误。

one, two = self.connection.store(msg_id, '-X-GM-LABELS', "\Inbox \Important \Sent \Seen")

Thanks! 谢谢!

Delete标记与Trash标记不同,因此,如果设置Delete,它将通过删除多余的标签将其移动到存档中

self.connection.store(msg_id, '+FLAGS', '\\Deleted') 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM