Search code examples
gmailgmail-api

gmail-api to check how many mails are unread and user has not replied to


I am developing an android app based on gmail-api in which I need to show how many mails are unread (based on a particular sender/subject) , and also need to show how many mails the user has not replied to (based on a particular sender/subject) . If anybody has done this pls let me know if this is feasible.


Solution

  • You need to use Users.messages: list method since it only return messages that match the specified query. It supports the same query format as the Gmail search box. For example, from:[email protected] rfc822msgid: is:unread.

    Based also from this related SO ticket, the q parameter (query) can be all kinds of stuff and it is the same as the gmail search bar on the top of the web interface. You can use this search method to find unread messages, for example like List<Message> unreadMessageIDs = ListMessages(service, "me", "is:unread");.

    Hope this helps! :)