Search code examples
gmailgoogle-api-php-clientgmail-api

How to fetch the "All Mail" label from the gmail api?


So when mail is archived in gmail, the message can be left without any labels attached.

In this case, the message is still accessible in the "All Mail" view.

I am using the gmail API, and I would like to represent All Mail as a label.

Is it possible to fetch the All Mail label via the API? I'm looking at the documentation here and I'm not seeing anything.

Also, in case it helps, I am using the google php client library to interact with this API.


Solution

  • You could have a All Mail-label in your application, and under the hood simply call User.messages: list with no labelIds given. That way you would get all the messages, disregarding labels completely.