Decoding of EmailMessage text
jak
nospam at please.ty
Mon Aug 23 18:54:40 EDT 2021
Il 23/08/2021 13:12, Loris Bennett ha scritto:
> Jon Ribbens <jon+usenet at unequivocal.eu> writes:
>
>> On 2021-08-23, Loris Bennett <loris.bennett at fu-berlin.de> wrote:
>>> If instead of
>>>
>>> mail.set_content(body)
>>>
>>> I do
>>>
>>> mail.set_content(body, cte="quoted-printable")
>>
>> Try print(mail.get_content()) rather than print(mail.as_string())
>
> That did the trick - thanks!
>
> Cheers,
>
> Loris
>
If you also want to know about the text, then that is probably utf8
encoded and converted to base64:
from base64 import b64decode
coded=(b'RGVhciBEci4gQmVubmV0dCwKCkJsb3JwISBCbGVlcCEKCgotLQpNYWlsYm90IEl'
b'uYy4KMDEwMTAxIEJvdCBCb3VsZXZhcmQKQm90aGFtIENpdHkKQsO2dGxhbmQK')
uncoded = b64decode(coded).decode('utf8')
print(uncoded)
output:
Dear Dr. Bennett,
Blorp! Bleep!
--
Mailbot Inc.
010101 Bot Boulevard
Botham City
Bötland
More information about the Python-list
mailing list