Python: Google API - Getting mimeTypes from a message

白昼怎懂夜的黑 提交于 2019-12-01 00:21:26

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!