Parse Gmail with Python and mark all older than date as quot;readquot;(使用 Python 解析 Gmail 并将所有早于日期的内容标记为“已读)
问题描述
长话短说,我创建了一个新的 gmail 帐户,并将其他几个帐户关联到该帐户(每个帐户都有 1000 条消息),我正在导入这些帐户.所有导入的邮件都以未读的形式到达,但我需要它们显示为已读.
Long story short, I created a new gmail account, and linked several other accounts to it (each with 1000s of messages), which I am importing. All imported messages arrive as unread, but I need them to appear as read.
我对python有一点经验,但是我只使用过mail和imaplib模块来发送邮件,没有处理账户.
I have a little experience with python, but I've only used mail and imaplib modules for sending mail, not processing accounts.
有没有办法批量处理收件箱中的所有项目,并将早于指定日期的邮件标记为已读?
Is there a way to bulk process all items in an inbox, and simply mark messages older than a specified date as read?
推荐答案
typ, data = M.search(None, '(BEFORE 01-Jan-2009)')
for num in data[0].split():
M.store(num, '+FLAGS', '\Seen')
这是对 imaplib 文档页面中的代码的轻微修改存储方法.我从 RFC 3501 中找到了要使用的搜索条件.这应该可以帮助您入门.
This is a slight modification of the code in the imaplib doc page for the store method. I found the search criteria to use from RFC 3501. This should get you started.
这篇关于使用 Python 解析 Gmail 并将所有早于日期的内容标记为“已读"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:使用 Python 解析 Gmail 并将所有早于日期的内容标记为“已读"


- YouTube API v3 返回截断的观看记录 2022-01-01
- 使用公司代理使Python3.x Slack(松弛客户端) 2022-01-01
- 使用 Cython 将 Python 链接到共享库 2022-01-01
- CTR 中的 AES 如何用于 Python 和 PyCrypto? 2022-01-01
- ";find_element_by_name(';name';)";和&QOOT;FIND_ELEMENT(BY NAME,';NAME';)";之间有什么区别? 2022-01-01
- 如何使用PYSPARK从Spark获得批次行 2022-01-01
- 我如何透明地重定向一个Python导入? 2022-01-01
- 计算测试数量的Python单元测试 2022-01-01
- 检查具有纬度和经度的地理点是否在 shapefile 中 2022-01-01
- 我如何卸载 PyTorch? 2022-01-01