GMail API: Fastest way to get the oldest email in inbox

若如初见. 提交于 2019-12-06 13:47:16

User.messages.list contains a paramter called q which can be used for searching.

https://www.googleapis.com/gmail/v1/users/userId/messagesq=before%3A2008%2F01%2F01&access_token={token}

Basicly before:2008/01/01 is sent just like searching in the gmail web app return all the emails before that date.

The trick here will be narrowing down your search. Gmail was released on 2004. Which gives yo possible start between 2018 and 2004 split it in half

before:2011/01/01  (there were mails split it in half again) 
before:2007/01/01  (there were no mails must be between 11 and 7)
before:2009/01/01  (...)

There is a term for this method of searching but i cant remember it right now. Basically you keep dividing it by two and finding out where the result must be.

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