In what order does the Gmail API return messages when you call "Users.messages: list"

As per the Gmail API reference , Users.messages: list "[lists] messages in user mailbox". From my observation, messages are returned in descending order of data. Is this assumption correct?

Basically, I want to be able to process a user's mailbox after a couple of days without processing messages that I've already processed. I would do this by stopping as soon as I came across an email that I saw before. Using history does not work reliably as it is documented that history can expire within hours, requiring a complete new sync.

+3


source to share


1 answer


Yes you are right. Messages are returned in descending order, first with the first.

You can save internalDate

new messages and list new messages with this value in the request after a few days.



Example

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

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

      

+2


source







All Articles