How to get message flags like “seen” in Gmail API

纵饮孤独 提交于 2019-12-08 19:46:29
Eric D

What do you mean by "flags" and "folders"? are you used to using IMAP and referring to it in that sense? what you normally would want is to look at labels like "UNREAD". those labels are the hardcoded, system labels and are documented at: https://developers.google.com/gmail/api/guides/labels

they are those exact values, never translated to other languages like the web user interface is.

gmail doesn't have "flags" or "folders" just labels. the flags and folder concepts are (somewhat hackily) provided to support IMAP. if you want to see all the unread message in the inbox just do something like:

>>> messages.list(labelIds=["INBOX", "UNREAD'])

Read/Unread status for a message is indicated by the presence of the UNREAD label. You can also see whether a message is starred. See Managing Labels.

You can do it as:

ListMessagesResponse emails = service.users().messages().list("me").setQ("label:UNREAD").execute();
// Getting my unread mails.

And it works with whatever language.

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