简体   繁体   English

使用python获取电子邮件正文

[英]Getting the email body using python

I'm quite new at this, but I've been trying to get the email body using python and I've tried almost all of the examples out there and I was able, with:我对此很陌生,但我一直在尝试使用 python 获取电子邮件正文,并且我已经尝试了几乎所有的示例,并且能够使用:

original = email.message_from_string(response_part[1].decode('utf-8'), policy=policy.default)

         data1 = original.get_body('text/plain')

to get this:得到这个:

Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: base64

SGkNCg==

in which the last line is actual my email body encoded with base64 but what I'm trying to do now is to actually get just the last line:其中最后一行实际上是我用 base64 编码的电子邮件正文,但我现在要做的是实际获取最后一行:

SGkNCg==

any suggestions?有什么建议?

其实很简单,只需要使用: get_payload()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM