Python: Google API - Getting mimeTypes from a message

后端 未结 1 1292
执念已碎
执念已碎 2021-01-06 12:03

My goal is to use the Google API to take data from an email I have specified. Currently I can find the message, get the message data and decode the message data into a reada

相关标签:
1条回答
  • 2021-01-06 12:18

    To iterate through the parts of a multipart message in Python, you should use get_payload(): https://docs.python.org/2/library/email.message.html#email.message.Message.get_payload

    In your example, the call to mime_msg['payload'] is looking up a message header named "payload", which doesn't exist and is not what you want anyway.

    Once you have a part in hand, you can check its type using part['Content-Type'] to examine the Content-Type header.

    In general, MIME messages are trees of parts, so you may need to recurse.

    0 讨论(0)
提交回复
热议问题