【问题标题】:how to get last email received or most recent inbox mail from Gmail API? [closed]如何从 Gmail API 获取最后收到的电子邮件或最近的收件箱邮件? [关闭]
【发布时间】:2016-04-07 21:17:56
【问题描述】:
I have already login through GoogleApiClient in my application.  
I am also able to List of email matching query using google api sample.

users.messages.list 通过此链接,我收到带有查询文本(搜索词)的用户电子邮件。

1.我需要使用 gmail api 收到的最后一封电子邮件。

【问题讨论】:

    标签: android email gmail gmail-api


    【解决方案1】:

    Listing 只是问题的一半:

    请求

    maxResults = 1
    q = -from:me
    
    GET https://www.googleapis.com/gmail/v1/users/me/messages?maxResults=1&q=-from%3Ame&access_token={YOUR_API_KEY}
    

    回应

    {
     "messages": [
      {
       "id": "1520a62ee385565e",
       "threadId": "1520a62ee385565e"
      }
     ],
     "nextPageToken": "17704551804303833190",
     "resultSizeEstimate": 1
    }
    

    之后需要Get具体邮箱:

    请求

    GET https://www.googleapis.com/gmail/v1/users/me/messages/1520a62ee385565e?access_token={YOUR_API_KEY}
    

    回应

    {
     "id": "1520a62ee385565e",
     "threadId": "1520a62ee385565e",
     "labelIds": [
      "INBOX",
      "CATEGORY_SOCIAL",
      "UNREAD"
     ],
     "snippet": "Snippet of the message",
     "historyId": "701108",
     "internalDate": "1451873198000",
     "payload": {
      "mimeType": "multipart/alternative",
    ...
    

    【讨论】:

      猜你喜欢
      • 2018-08-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-05-15
      • 1970-01-01
      • 2020-02-13
      • 2021-04-19
      • 2013-12-19
      相关资源
      最近更新 更多