Object has no attribute 'encode' <p>I'm trying to attach an xlsx file to my email. I looked up solutions and it involves using email.encoders. But when I use this solution I get an error. I'm using a solution that someone else has working.</p> <pre><code>File "C:\Documents and Settings\Desktop\AppTera\dev\MTC_test\MTC_sender.py", line 41, in sendmail s.sendmail(FROMADDR, TOADDR, message.as_string()) AttributeError: 'list' object has no attribute 'encode' </code></pre> <pre><code>def sendmail(): SERVER = 'server.com' FROMADDR = "joe@example.com" TOADDR = ['bob@example.com'] CCADDR = ['bill@example.com'] message = MIMEMultipart('mixed') message['From'] = FROMADDR message['To'] = TOADDR message['Subject'] = "Reporting for IVR Application" BODY = "Hello Angela,\n\nI'm attaching the reports for %s/%s. These are the same reports\ you have requested in the past.\n\nPlease let me know if you need any additional reports.\n\n\ Thank you"% (str(MONTH), str(YEAR)) message.attach(MIMEText(BODY, 'plain')) filename = "results.csv.xlsx" path = r'C:\Documents and Settings\Desktop\MonthlyReports\MTC\%s_%s' % (str(YEAR), str(MONTH)) os.chdir(path) fileMsg = MIMEBase('application', 'xlsx') fileMsg.set_payload(open('results.csv.xlsx', 'rb').read()) encoders.encode_base64(fileMsg) fileMsg.add_header('Content-Disposition','attachment;filename=results.csv.xls') message.attach(fileMsg) s = smtplib.SMTP(SERVER, 25) s.set_debuglevel(1) s.sendmail(FROMADDR, TOADDR, message.as_string()) s.quit() </code></pre> <p>Is there another way that I can send an attached file along with a body message?</p>