0

This code print emails from gmail, but when i print 'body' shows only a part of mail. I've founded that there is more or less 200 chars in output, so probably message is too large to be a string, but I don't know how to solve it. Maybe hould i save these mails to diffrend type.

results2 = service.users().messages().list(userId='me').execute()
messageids = results2.get('messages', [])
for messageids in messageids:

    message =(service.users().messages().get(userId='me',id=messageids['id']).execute())
    body = message['snippet']

Thanks for any help.

Linda Lawton - DaImTo
  • 106,405
  • 32
  • 180
  • 449
  • 1
    If you look at [Users.messages](https://developers.google.com/gmail/api/v1/reference/users/messages), it says that 'snippet' is "A short part of the message text." You probably want to look in the 'payload' parts. – Andrew Morton Jan 11 '19 at 14:08

1 Answers1

0

Based from this thread: Python imaplib fetch body emails gmail, you can get the contents of the body by doing any of the following:

msg.as_string()
str(msg)
repr(msg)

Source: https://docs.python.org/2.7/library/email.message.html#email.message.Message

You may also check this thread for additional reference.

abielita
  • 13,147
  • 2
  • 17
  • 59