Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 892
tbreier Avatar asked Mar 22 '17 19:03

tbreier


People also ask

Where is the message list in Gmail?

The message list is the group of emails in the center of the Gmail page. You can also show or hide a Label from the message list by clicking "show" or "hide". A hidden label in the message list makes your Inbox neater, while a label that is shown in the message list makes it easier to identify the specific email.


1 Answers

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
like image 100
Tholle Avatar answered Nov 13 '22 15:11

Tholle