检测已发送邮件的ID

时间:2015-08-24 14:52:04

标签: xmlhttprequest gmail gmail-api

我想检测电子邮件的消息ID

从gmail界面发送?

你的建议是什么?

感谢。

1 个答案:

答案 0 :(得分:0)

这样做的一种方法是首先列出消息:

GET https://www.googleapis.com/gmail/v1/users/me/messages

<强>响应:

{
 "messages": [
  {
   "id": "14f60b097be71757",
   "threadId": "14f60b097be71757"
  },
  {
   "id": "14f603ead78aff97",
   "threadId": "14f603ead78aff97"
  }, ...

然后,获取您想要的消息,并只询问Message-Id - 标题:

format = metadata
metadataHeaders = Message-Id

GET https://www.googleapis.com/gmail/v1/users/me/messages/14f60b097be71757?format=metadata&metadataHeaders=Message-Id

<强>响应:

{
 "id": "14f60b097be71757",
 "threadId": "14f60b097be71757",
 "labelIds": [
  "INBOX",
  "CATEGORY_PROMOTIONS",
  "UNREAD"
 ],
 "snippet": "Cool snippet...",
 "historyId": "545168",
 "internalDate": "1440436229000",
 "payload": {
  "mimeType": "multipart/alternative",
  "headers": [
   {
    "name": "Message-Id",
    "value": "<10342275.20150824171029.55db500501e9a7@example.com>" // Here it is!
   }
  ]
 },
 "sizeEstimate": 73995
}