Gmail API检索电子邮件,但没有他们的内容

发布于 2025-02-12 19:05:15 字数 1636 浏览 3 评论 0 原文

我正在使用Gmail API为自己为自己制作一个简单的电子邮件摘要脚本,但是我遇到了一个问题,其中仅处理了一些电子邮件。例如,假设我有3封电子邮件。我将能够检索第一个的身体内容,但其他2个说,他们在很大程度上没有任何内容。

78      for mail in emails:
79          # extract body of email                                                                                                                                 
80          content = msgs.get(userId = 'me', id = mail['id'], format =
81      "full").execute()['payload']
82          print()
83          print(content["body"])
84          print()

where emails = service.users()。消息()。列表(userId ='me',q = query).execute()['message'] and q只是过滤器 query =“标签:不需要的消化”

输出看起来像这样:


{'size': 0}

{'size': 44866, 'data':'PCFET0NUWVBFIGh0bWw-DQo8aHRtbCBsYW5nPSJlbiI-DQo8aGVhZD4NCjx0aXRsZT50.........

{'size': 0}

我可以从第二封电子邮件中读取数据,但不能从其他电子邮件中读取数据。这使我感到困惑,因为当我打印出内容的输出[“标题”)时,我会得到这些电子邮件确实存在的证据。

6 Algorithms Every Developer Should Know | Richard Warepam in Dare To Be Better [email protected] Fri, 01 Jul 2022 14:30:00 +0000 (UTC)

The ONLY sustainable sale: Up to 60% off + free shipping thredUP <[email protected]> Fri, 1 Jul 2022 02:44:06 -0700

What makes senior software engineers laugh when they look at a junior engineer's code?  Fri, 01 Jul 2022 02:01:31 +0000

这种差异的原因是什么?

I'm working on a simple email digest script for myself using the Gmail API, but I've run into an issue where only some emails are processed correctly. For example, suppose I have 3 emails. I will be able to retrieve the body contents of the first, but the other 2 say that they don't have any content when they very much do.

78      for mail in emails:
79          # extract body of email                                                                                                                                 
80          content = msgs.get(userId = 'me', id = mail['id'], format =
81      "full").execute()['payload']
82          print()
83          print(content["body"])
84          print()

where emails = service.users().messages().list(userId='me', q = query).execute()['messages'] and q is just the filter query = "label:unwanted-for-digest"

The output looks something like this:


{'size': 0}

{'size': 44866, 'data':'PCFET0NUWVBFIGh0bWw-DQo8aHRtbCBsYW5nPSJlbiI-DQo8aGVhZD4NCjx0aXRsZT50.........

{'size': 0}

I can read the data from the second email, but not from the rest. This confuses me because when I print out the output of content["headers"], I get proof that these emails do exist.

6 Algorithms Every Developer Should Know | Richard Warepam in Dare To Be Better [email protected] Fri, 01 Jul 2022 14:30:00 +0000 (UTC)

The ONLY sustainable sale: Up to 60% off + free shipping thredUP <[email protected]> Fri, 1 Jul 2022 02:44:06 -0700

What makes senior software engineers laugh when they look at a junior engineer's code?  Fri, 01 Jul 2022 02:01:31 +0000

What's the cause for this discrepancy?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

你对谁都笑 2025-02-19 19:05:15

在审查了代码的有效载荷后,我们注意到该结构为a Multipart/Digest容器,因此信息列表存储在不同的部分中。

After reviewing the payload of the code, we noticed that the structure was a multipart/digest container, so the information list was stored in a different part.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文