title: Python - Extract the body from a mail in plain text
body: <p>I want to extract only the body of a message and return it.
  I can filter on the fields and display the snippet but not the body.</p>
  
  <pre><code>def GetMimeMessage(service, user_id, msg_id):
      try:
              message = service.users().messages().get(userId=user_id, id=msg_id, format='raw').execute()
              print 'Message snippet: %s' % message['snippet']
              msg_str = base64.urlsafe_b64decode(message['raw'].encode('ASCII'))
              mime_msg = email.message_from_string(msg_str)
              return mime_msg
      except errors.HttpError, error:
              print 'An error occurred: %s' % error
  </code></pre>
  
  <p><a href="https://developers.google.com/gmail/api/v1/reference/users/messages/get" rel="noreferrer">https://developers.google.com/gmail/api/v1/reference/users/messages/get</a></p>