change raw message to email.message_from_bytes
This commit is contained in:
@@ -1009,10 +1009,7 @@ def demandes_dl(request):
|
|||||||
request.session.flash("ERREUR de lecture du message %S-%s" % (email_from, email_uid), 'danger')
|
request.session.flash("ERREUR de lecture du message %S-%s" % (email_from, email_uid), 'danger')
|
||||||
return HTTPFound(location=request.route_url('messages'))
|
return HTTPFound(location=request.route_url('messages'))
|
||||||
|
|
||||||
raw_email = msg_data[0][1]
|
email_message = email.message_from_bytes(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)
|
|
||||||
|
|
||||||
# get the message's body
|
# get the message's body
|
||||||
body = ''
|
body = ''
|
||||||
@@ -1025,7 +1022,6 @@ def demandes_dl(request):
|
|||||||
body = part.get_payload(decode=True) # decode
|
body = part.get_payload(decode=True) # decode
|
||||||
break
|
break
|
||||||
|
|
||||||
# import pdb;pdb.set_trace()
|
|
||||||
# downloading attachment
|
# downloading attachment
|
||||||
temp_file_path = download_pdf_to_tmp(email_message)
|
temp_file_path = download_pdf_to_tmp(email_message)
|
||||||
if temp_file_path != '':
|
if temp_file_path != '':
|
||||||
|
|||||||
Reference in New Issue
Block a user