From f1fc5a24c1a891029f042005678bde72e9c87879 Mon Sep 17 00:00:00 2001 From: quenousimporte Date: Wed, 10 Apr 2024 17:38:31 +0200 Subject: [PATCH] fix encoding --- imap2md/export-imap-notes.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/imap2md/export-imap-notes.py b/imap2md/export-imap-notes.py index 5cd6cbe..8370b7c 100644 --- a/imap2md/export-imap-notes.py +++ b/imap2md/export-imap-notes.py @@ -56,13 +56,12 @@ for i in range(messages, messages-N, -1): content_type = msg.get_content_type() body = msg.get_payload(decode=True).decode() if content_type == "text/plain": - open(filepath, "w").write(body) + open(filepath, "wb").write(body.encode('utf8')) if content_type == "text/html": md = markdownify(body) if md[:4] == 'html': md = md[4:] - open(filepath, "wb").write(md.encode('utf8')) imap.close()