diff --git a/gpgmymail b/gpgmymail index 8b51754..21c46e6 100755 --- a/gpgmymail +++ b/gpgmymail @@ -55,14 +55,17 @@ def decode_email(message: email.message.Message) -> email.message.Message: :param message: email.message.Message to be decoded :return: decoded email.message.Message""" - payload = [] + if message.is_multipart(): + payload = [] + for part in message.walk(): + if not part.is_multipart(): + payload.append(part.get_payload(decode=True)) - for part in message.walk(): - if not part.is_multipart(): - payload.append(part.get_payload(decode=True)) + message.set_payload(payload) + else: + message.set_payload(message.get_payload(decode=True)) message["Content-Transfer-Encoding"] = "7bit" - message.set_payload(payload) return message