Feb-06-2018, 10:59 AM
It might be because your are encoding (base64) the attachment in the line 203.
You will need only encode it, for MIMEBase.
So what you can try to do is change the code to this:
encoders.encode_base64(attachement) #https://docs.python.org/3/library/email-examples.htmlThe MIMEImage, MIMEAudio, MIMEApplication already uses base64 encoding as default. So you don't need to encode the attachment.
You will need only encode it, for MIMEBase.
So what you can try to do is change the code to this:
else: attachement = MIMEBase(main_type, sub_type) temp = open(attached_file, 'rb') attachement.set_payload(temp.read()) temp.close() #-----3.3 encode the attachment, add a header and attach it to the message encoders.encode_base64(attachement) #https://docs.python.org/3/library/email-examples.html filename = os.path.basename(attached_file)Give it a try and see if it will work now.