...
# attachment
mimetype, encoding = guess_type('test.xlsx')
print(mimetype, encoding)
mimetype = mimetype.split('/', 1)
print(mimetype)
fp = open('test.xlsx', 'rb')
attachment = MIMEBase(mimetype[0], mimetype[1])
attachment.set_payload(fp.read())
fp.close()
encoders.encode_base64(attachment)
attachment.add_header('Content-Disposition', 'attachment', filename='test.xlsx')
msg.attach(attachment)
...
# attachment
mimetype, encoding = guess_type('test.xlsx')
print(mimetype, encoding)
mimetype = mimetype.split('/', 1)
print(mimetype)
fp = open('test.xlsx', 'rb')
attachment = MIMEBase(mimetype[0], mimetype[1])
attachment.set_payload(fp.read())
fp.close()
encoders.encode_base64(attachment)
attachment.add_header('Content-Disposition', 'attachment', filename='test.xlsx')
msg.attach(attachment)
...
