Home > Enterprise >  Why does "category:social" with in GMail UI search, but does not work in GmailApp.search(&
Why does "category:social" with in GMail UI search, but does not work in GmailApp.search(&

Time:10-05

So putting "category:social" in the GMail UI correctly returns email in the Social tab.

Putting const threads = GmailApp.search("category:social", 0, 500); returns nothing.

The social categorized emails DO appear under const threads = GmailApp.search("category:updates", 0, 500);

Am I not understanding how GMail uses the Category label?

CodePudding user response:

The GMAIL UI and Apps Script searches return exactly the same results

You can test again by e.g. modifying your code as following and view the logs:

function test(){
  const threads = GmailApp.search("category:social", 0, 500); 
  threads.forEach(function(thread){
  console.log(thread.getFirstMessageSubject())
  })
}

Btw., the category label can be adjusted by you as desired - either from the Gmail UI or Gmail API

You can view /edit your labels when opening an email and clicking on the label icon:

enter image description here

  • Related