[英]How to get thread id from gmail for a certain email
I want to find the thread id for a certain email which I have sent from gmail.我想找到我从 gmail 发送的某个电子邮件的线程 ID。 I went through the Gmail apis, in which there are methods to get the list of threads as well as a method which gives you all the messages related to that thread after you send the user id ie email and thread id.
我浏览了 Gmail api,其中有一些方法可以获取线程列表,还有一种方法可以在您发送用户 ID(即电子邮件和线程 ID)后为您提供与该线程相关的所有消息。 I can use the list method to get thread id but is there any alternate way to get the thread id?
我可以使用 list 方法来获取线程 id 但有没有其他方法来获取线程 id?
If you just have the messageId
, you could get the message , specifically asking just for the threadId
of that message:如果您只有
messageId
,则可以获得 message ,特别是仅询问该消息的threadId
:
Request要求
usedId = me
id = 1514453c0800d5fa
fields = threadId
GET https://www.googleapis.com/gmail/v1/users/me/messages/1514453c0800d5fa?fields=threadId&access_token={YOUR_API_KEY}
Response回复
{
"threadId": "1514453c0800d5fa"
}
Then, just use this to get the thread :然后,只需使用它来获取线程:
Request要求
userId = me
id = 1514453c0800d5fa
GET https://www.googleapis.com/gmail/v1/users/me/threads/1514453c0800d5fa?access_token={YOUR_API_KEY}
Also, if you know the message is the first message in the thread, the threadId
will be the same as the messageId
, as in the example above.此外,如果您知道该消息是线程中的第一条消息,则
threadId
将与messageId
相同,如上例所示。
If you don't have Google's own messageId
but the Message-ID , you have to list the message as you said:如果您没有 Google 自己的
messageId
而是Message-ID ,则必须按照您所说的列出消息:
Request要求
userId = me
q = rfc822msgid:<Message-ID>
GET https://www.googleapis.com/gmail/v1/users/me/messages?q=rfc822msgid%3A%3C0000015148b39f7a-64856e69-3b6e-4e37-bff0-db4e26aae420-000000%40eu-west-1.amazonses.com%3E&access_token={YOUR_API_KEY}
Response回复
{
"messages": [
{
"id": "15148b3a2f9a26a0",
"threadId": "15148b3a2f9a26a0"
}
],
"resultSizeEstimate": 1
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.