How to get unread mails from primary inbox in Gmai

2020-04-16 01:54发布

问题:

I'm using the Javascript client API with my app and I'm trying to get unread mails from the primary inbox.

If I use the INBOX and UNREAD names when requesting the labels I get all unread mails from all labels.

No other label type name works, I've experimented in APIs explorer and i can't seem to figure out how to manage this.

Am I missing something or is it not possible?

回答1:

You can try this "in:inbox is:unread -category:(promotions OR social)" as a value for q parameter in messages.list. I tried this in API explorer, and it gave correct results.

I have 4 "UNREAD" mails(or Threads) in my inbox, and response is:

200 OK

{
 "messages": [
  {
   "id": "14aea080215aa680", --- Thread 1
   "threadId": "14aea080215aa680"
 },
 {
  "id": "14ae8e25e92657e3", --- Thread 2
   "threadId": "14ae8e25e92657e3"
  },
 {
  "id": "14ae5e7a8bb1bc2f",-- Thread 3
  "threadId": "14ae433c5ae8de64"
 },
{
  "id": "14ae439fd8cd3726",-- Same thread 3 with different message id
  "threadId": "14ae433c5ae8de64"
 },
{
  "id": "14ae433c5ae8de64",-- Same thread 3 with different message id
  "threadId": "14ae433c5ae8de64"
 },
{
  "id": "14ae33d8431a06f3",-- Thread 4
  "threadId": "14ae33d8431a06f3"
}
],
  "resultSizeEstimate": 6
}


回答2:

Try also this "in:inbox is:unread category:primary"



回答3:

You could try "in:unread category:primary "