使用 IMAP4 和 python 从 GMail 获取加星标的邮件
我发现了许多有关使用 IMAP 的虚拟信息,但我不明白如何将其用于我的目的。我找到了如何从邮箱中获取所有邮件和所有已看到的邮件,但是我应该如何使用星星? 请给我一个 python 代码示例,用于通过 IMAP4 从 GMail 获取加星标的邮件、检查某条邮件是否加星标、为某条邮件加星标和取消星标。
I found many dummy info about working with IMAP, but I didn't understand how to use it for my purposes. I found how I can get ALL messages from mailbox and ALL SEEN messages, but how should I work with stars?
Please, give me examples of python code for getting starred messages from GMail through IMAP4, for checking if some message is starred or unstarred, for starring and unstarring some one message.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Gmail 的“已加星标”状态直接映射到 IMAP
\Flagged
关键字。因此,您可以通过在邮件上设置或取消设置\Flagged
来切换邮件的星标:您可以通过搜索
FLAGGED
来搜索已加星标的邮件(或通过搜索未加星标的邮件) UNFLAGGED
):Gmail 甚至为您提供一个包含所有加星标邮件的虚拟文件夹。如果您
选择“[Gmail]/已加星标”
,您将看到邮箱中所有已加星标的邮件:Gmail's "Starred" state maps directly onto the IMAP
\Flagged
keyword. So you can toggle a message's star by setting or unsetting\Flagged
on the message:You can search for starred messages by searching for
FLAGGED
(or for unstarred messages viaUNFLAGGED
):Gmail even gives you a virtual folder containing all starred messages. If you
SELECT "[Gmail]/Starred"
, you'll get a view of all the starred messages in the mailbox:我的外部库: https://github.com/ikvk/imap_tools
My external lib: https://github.com/ikvk/imap_tools