Decoding of EmailMessage text

Loris Bennett loris.bennett at fu-berlin.de
Tue Aug 24 01:39:39 EDT 2021


jak <nospam at please.ty> writes:

> 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

Thanks!  I don't need that right now, but it's good to know which
decoding hoop I would have to jump through, if I did.

Cheers,

Loris

-- 
This signature is currently under construction.


More information about the Python-list mailing list