Search for email using message-id using Gmail API in Python

Viewed 654

I am trying to get a particular email by searching for its message-id using the following API: https://developers.google.com/gmail/api/guides/filtering

e.g message_id = "<C6P4M-GEE8PzO8qf0=oTQ3ZJeFB_uASDAAF9AJSRRiNuUVBzan0w@mail.gmail.com>"

Could I implement it by modifying the following:

MESSAGE = GMAIL.users().messages().list(userId='me',labelIds='INBOX').execute()

But how do I modify it to search only for the particular email with the message_id?

Currently I have tried using an extremely inefficient solution which works by scanning the entire inbox using messages.list and then find the matching email message-id.

1 Answers
Related