Skip to content Skip to sidebar Skip to footer

Python Gmail Api Won't Pass Labelids Parameter To List Method

I've been trying to get a Python script set up that involves querying a Gmail account for unread messages. Ideally I'd like to make use of the Gmail API's 'list' method with the op

Solution 1:

How about this modification? I think that there are several patterns for your situation.

Pattern 1:

results = service.users().messages().list(userId='me', labelIds=['UNREAD']).execute()

For example, if you want to retrieve the unread messages in the inbox, you can use userId='me', labelIds=['UNREAD', 'INBOX'] and userId='me', labelIds=['UNREAD'], q='in:inbox'.

Pattern 2:

results = service.users().messages().list(userId='me', q='is:unread').execute()

For example, if you want to retrieve the unread messages in the inbox, you can use userId='me', q='in:inbox is:unread'.

References:

If I misunderstand your question, I'm sorry.

Post a Comment for "Python Gmail Api Won't Pass Labelids Parameter To List Method"