change raw message to email.message_from_bytes

This commit is contained in:
2020-12-11 13:17:25 +01:00
parent 862d90657e
commit ef9e56a272

View File

@@ -1009,10 +1009,7 @@ def demandes_dl(request):
request.session.flash("ERREUR de lecture du message %S-%s" % (email_from, email_uid), 'danger')
return HTTPFound(location=request.route_url('messages'))
raw_email = msg_data[0][1]
# converts byte literal to string removing b''
raw_email_string = raw_email.decode('utf-8')
email_message = email.message_from_string(raw_email_string)
email_message = email.message_from_bytes(msg_data[0][1])
# get the message's body
body = ''
@@ -1025,7 +1022,6 @@ def demandes_dl(request):
body = part.get_payload(decode=True) # decode
break
# import pdb;pdb.set_trace()
# downloading attachment
temp_file_path = download_pdf_to_tmp(email_message)
if temp_file_path != '':