有没有办法使用 Google Mail API 按接收时间排序列出 Gmail 邮件?
虽然 API 返回的邮件是按时间倒序排列的。对于像 10 封邮件这样的非常小的数据集,我发现了差异。
邮件列表API的响应:
{
"messages": [
{
"id": "15afb61b8d220a19",
"threadId": "15afb61b8d220a19"
},
{
"id": "15afb618f941d73f",
"threadId": "15afb618f941d73f"
},
{
"id": "15afb6174711c7af",
"threadId": "15afb6174711c7af"
},
...
...
{
"id": "159bc283f63d5eb7",
"threadId": "159bc283f63d5eb7"
},
{
"id": "159bc283dc97cd87",
"threadId": "159bc283dc97cd87"
},
{
"id": "159bc283d95f097c",
"threadId": "159bc283d95f097c"
}
],
"resultSizeEstimate": 9
}
响应中的第一条消息(最新):
Id: 15afb61b8d220a19
Date: "Thu, 23 Mar 2017 19:06:08 +0530"
internalDate: "1490276168000"
列表中的第二封邮件:
Id: 15afb618f941d73f
Date: "Thu, 23 Mar 2017 19:05:58 +0530"
internalDate: "1490276158000"
... ... 列表中倒数第二封邮件:
Id: 159bc283dc97cd87
Date: "Fri, 20 Jan 2017 05:54:30 -0800"
internalDate: "1484920470000"
列表中的最后一封邮件(应该是最早的,但不是):
Id: 159bc283d95f097c
Date: "Fri, 20 Jan 2017 05:54:31 -0800"
internalDate: "1484920471000"
最佳答案
我猜这是基于此 thread 的预期行为.
...
messages.list
does NOT return in date ASC or date DESC. They are returned randomly as far as I can tell.
您还可以使用 search syntax按电子邮件的日期过滤。
关于google-api - Gmail API - 有没有一种方法可以按 w.r.t. 的排序顺序列出邮件?接收时间?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43072057/