title: Decoding MIME email from Gmail API - \r\n and 3D - Python
body: <p>I am currently using the Gmail API to read in some HTML emails in Python. I've decoded their body using:</p>
  
  <pre><code>base64.urlsafe_b64decode
  </code></pre>
  
  <p>After printing out the resulting HTML email, "\r\n" and "3D" are scattered around the HTML. I can't remove the "\r\n" because the \ and r and \ and n register as different characters (?) and I'm not sure where the "3D" comes from.</p>
  
  <p>Is there something wrong with how I'm decoding it?</p>
  
  <p>Here is the code:</p>
  
  <pre><code>results = service.users().messages().list(userId='me', q = 'is: unread').execute()
  
  for index in range(len(results['messages'])):
      message = service.users().messages().get(userId='me', id=results['messages'][index]['id'], format='raw').execute()
  
      msg_str = base64.urlsafe_b64decode(message['raw'].encode('UTF-8'))
  
      mime_msg = email.message_from_string(str(msg_str))
  
      print(mime_msg)
  
      service.users().messages().modify(userId='me', id=results['messages'][index]['id'], body = {'removeLabelIds': ['UNREAD']}).execute() # mark message as read
  </code></pre>