After flashing the latest build from
http://micropython.org/resources/firmwa ... 0abcf2.bin
umail worked again

as attaching a .csv file will be easier than copying up to 120K of text in a text editor and giving it a .csv name.RFC2045-compliant multipart message string
Code: Select all
# open the file to be sent
filename = my_file
attachment = open(my_file, 'rb')
# instance of MIMEBase and named as p
p = MIMEBase('application', 'octet-stream')
# To change the payload into encoded form
p.set_payload((attachment).read())
# encode into base64
encoders.encode_base64(p)
p.add_header('Content-Disposition', 'attachment; filename= %s' % filename)
# attach the instance 'p' to instance 'msg'
msg.attach(p)
Code: Select all
# instance of MIMEMultipart
msg = MIMEMultipart()
Code: Select all
smtp.write("Content-Type: image/jpeg; name=cam.jpeg\n")
smtp.write("Content-Disposition: attachment; filename="cam.jpeg"\n")
Code: Select all
# build today's filename into Content-Type and Content-Disposition
csv_file = 'House-' + date + '.csv\n'
content_type = 'Content-Type: text/csv; name=' + csv_file
content_disposition = 'Content-Disposition: attachment; filename=' + csv_file
smtp.write(content_type)
smtp.write(content_disposition)