Feb-07-2018, 04:33 PM
Quote:To fix you have 2 options, you can try to read line by line (by using readline) and add "\r\n" in the end of each line.
Or you can try to open the Text File in binary mode:
Python Code: (Double-click to select all)
if main_type == 'text': print("text") temp = open(attached_file, 'rb') # 'rb' will send this error: 'bytes' object has no attribute 'encode' attachement = MIMEText(temp.read(), _subtype=sub_type) temp.close()I didn't test the solution above, but you can give a try and see if it Works.
Using 'rb' will send an error 'bytes' object has no attribute as it's mentioned in the comment besides the code you posted. How would the code be with readline?