How can I print the subject and body of a GMail email using the python API?
问题 results = service.users().messages().list( userId='me', labelIds=['INBOX'], maxResults=1).execute() labels = results.get('messages', []) if not labels: print('No labels found.') else: print('Labels:') for label in labels: print(label['id']) This script prints the message Id of the most recent email. How can I print the subject and body of the emails? I can't find any documentation on how to do it 回答1: 1. To make your coide less confusing it is recommended to call your messages as such rather