I used Python’s imaplib to pull mail from a gmail account… but I got an email with this confusing text body:
> RGF0ZSBldCBoZXVyZTogICAgICAgICAgICAgICAgICAgICAgICAgICAyMi8wOC8yMDEwIDE0
> OjMzOjAzIEdNVCBVbmtub3duDQpQcsOpbm9tOiAgICAgICAgICAgICAgICAgICAgICAgICAg
> ICAgICAgICAgamFjaW50bw0KTm9tOiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
> ICAgICBjYXJ2YWxobw0KRS1NYWlsOiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
who can help me to read this file from my email…
Thx
lo
It looks like base64. In Python you can either use
base64.b64decodeorstr.decode('base64').Result:
The
élooks like it is incorrect. It appears that the text was encoded in UTF-8, so you also need to decode the UTF-8 encoding:Result:
One other thing to be aware of is that there are different variants of Base64 encodings that differ in the two symbols they use for value 62 and 63. Using
base64.b64decodeyou can specify these two characters if the defaults don’t work for you.