Hassan Anwer
Hassan Anwer

Reputation: 367

Read All Emails In a Domain

I want to read all emails in my domain against a query using API. Currently, I am enumerating one user at a time and extracting all the emails for it

list(userId, includeSpamTrash=None, labelIds=None, maxResults=None, pageToken=None, q=None, x__xgafv=None)

This approach is not scalable as in the case of 1000+ users it will take a lot of time. I want to extract the emails for all users against a query but without enumerating userId

Upvotes: 0

Views: 347

Answers (1)

Linda Lawton - DaImTo
Linda Lawton - DaImTo

Reputation: 116868

The message.list method does not return a full message object it only returns the message id and the thread id.

"messages": [
    {
      "id": "178a78eef21cc0fa",
      "threadId": "178a78eef21cc0fa"
    },
    {
      "id": "178a77fd677004b8",
      "threadId": "178a738e29b7812d"
    },
    {
      "id": "178a778d32097a98",
      "threadId": "178a738e29b7812d"
    },

If you want more information about the message then you will need to run a message.get which does return a full message object

I guess what i am saying is this approach may not be scalable in your case but it is your only option.

You could try batching the requests but i haven't personally had much luck with batching you will need to check that the Python client library was updated to use the new batching endpoint Im not sure if they have updated it yet.

Upvotes: 1

Related Questions