In what order does the Gmail API return messages when calling “Users.messages: list”

前提是你 提交于 2019-12-07 05:49:37

问题


According to the Gmail API reference, Users.messages: list "[lists] the messages in the user's mailbox". In my observation, the messages are returned in descending order by data. Is this a correct assumption?

Basically I want to be able to process a user's inbox after a couple of days without reprocessing messages I have already processed. I would do that by stopping once I stumble upon an email I have seen before. Using the history doesn't work reliable, since it is documented that history might expire within a few hours, requiring a full new sync.


回答1:


Yes, you are correct. Messages are returned in descending order, with the newest one first.

You could save the internalDate of the newest message and list new messages with that value in the query a few days later.

Example

internalDate = 1490213949000 // Wed Mar 22 2017 21:19:09 GMT+0100 (CET)

q=after:1490213949 // 'after' takes seconds since the epoch. internalDate/1000


来源:https://stackoverflow.com/questions/42960538/in-what-order-does-the-gmail-api-return-messages-when-calling-users-messages-l

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!