【问题标题】:Is it possible to get recent 10 emails using Gmail-api?是否可以使用 Gmail-api 获取最近的 10 封电子邮件?
【发布时间】:2018-01-30 03:39:05
【问题描述】:

目前,我可以使用 gmail api 来获取所有未读邮件或收件箱中的所有邮件。

GMAIL.users().messages().list(userId='me', labelIds=['UNREAD', 'INBOX']).execute()

因为获取所有电子邮件可能很烦人,我想知道是否有可能只从 gmail api 获取最近的 10 封 UNREAD 电子邮件?

感谢任何提示,让我可以做这样的事情。

【问题讨论】:

    标签: python gmail-api


    【解决方案1】:

    documentation 告诉我们需要传递 maxResults 并将其设置为 10:

    GMAIL.users().messages().list(userId='me', labelIds=['UNREAD'], maxResults=10).execute()
    

    【讨论】:

      【解决方案2】:

      通过这个doc

      您可以使用高级搜索选项进行查询。

      你可以使用

      比更新:

      示例:newer_than:2d

      使用 d(日)、m(月)和 y(年)搜索比某个时间段更早或更晚的消息

      【讨论】:

      • 此文档适用于 gmail 而不是 gmail-API
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-01-09
      • 2015-11-16
      • 2011-08-03
      • 2023-03-14
      • 1970-01-01
      • 2018-08-25
      • 2016-10-27
      相关资源
      最近更新 更多