Search code examples
google-apps-scriptgmail

Gmail - move email to a category


I want to use Google Script to move an email to a specified category (e.g. Updates). How do I do this? I tried treating categories as labels, but that does not work.


Solution

  • You can use Gmail Advanced API in Apps Script to apply a category on email.

    Gmail.Users.Threads.modify({"addLabelIds": ["CATEGORY_UPDATES"]}, userId, threadId)
    

    You can also try the Rest API here