I am working on getting large text corpus of the email. There is no API that allows reading a message in Google Group. So the alternative way is to use a Gmail account which is a member of that group. By using this Gmail I can check all the message that is sent to that group. I am using python and Gmail API to fetch the mail. The problem I face is, I couldn't fetch the emails which are from the groups.
results = service.users().messages().list(userId='me',q="from:[email protected]", maxResults=10).execute()
When I replace the from:
with another normal user id it's working. When I replace the from:
with group email id it's giving zero results. Could I get the actual code to fetch the group gmails through my Gmail?
the second problem is,
when i query using someones's mail :
results = service.users().messages().list(userId='me',q="from:[email protected]", maxResults=10).execute()
I get the results like that
{'resultSizeEstimate': 82, 'messages': [{'id': '1653929b0b414390', 'threadId': '1644c19f390faf28'}, {'id': '165330aaa5bb9134', 'threadId': '16532ef13e7eec8d'}......
Here it's only returning the message id. In order to get the mail with a body with headers, I have to query again for every id. Can't I get the full JSON in one query?
get
method for every id returned, and you can specify thefields
parameter to return only the data you need (for better performance and less bandwidth usage). – Shout