【问题标题】:How we can find the message id which we have to provide to gamil api to get the message via python (imap,email module)我们如何找到必须提供给gmail api以通过python(imap,email模块)获取消息的消息ID
【发布时间】:2020-10-06 04:38:46
【问题描述】:

我能够获取 uid 和 message-id,但无法通过 google api 解码该消息 id 以使用,我可以在其中找到有关它的更多信息。

我想从该消息 id 中获取线程 id

使用python3.7

import imaplib, email

mail = imaplib.IMAP4_SSL('imap.gmail.com')
username = 'id'
password = 'password'
mail.login(username, password)
mail.list()
# Out: list of "folders" aka labels in gmail.
mail.select("inbox") # connect to inbox.

date = (datetime.date.today() - datetime.timedelta(1)).strftime("%d-%b-%Y")
result, data = mail.uid('search', None, '(SENTSINCE {date})'.format(date=date))
email_uid = data[0].split()
for uid in email_uid[:
  print(mail.uid('fetch', uid, '(RFC822)'))

请尽快提供帮助

【问题讨论】:

标签: python-3.x email gmail imap gmail-api


【解决方案1】:

您很可能需要一个 uid。

阅读https://www.rfc-editor.org/rfc/rfc3501#page-8

这个库可以帮助你:https://github.com/ikvk/imap_tools

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-12-08
    • 1970-01-01
    • 2016-05-29
    • 2013-04-02
    相关资源
    最近更新 更多