Emailing an excel sheet with SSL in Python -


This is my first post, so I know there are any common manners that I should know about.

I was just starting programming up 8 months ago, so I am quite new. I am doing some projects to get better. A project on which I am working now creates excel sheets from inputted data. It's in Python, which I just started learning a few weeks ago. I am trying to embed a portion of this Excel sheet into an email, which has been sent from my school address.

There are two problems with asking for help with I:

1) The following code works to send emails from Gmail, but my school account is unfortunately unfortunately, I am having trouble setting up the outgoing email for this account on my iPhone, can it be related? Does anyone have the idea why this code does not work?

  Import from email smtplib MIMEText LOGIN = 'myemailaddress' PASSWORD =' mypassword 'def sendmail email, To_addr = LOGIN): msg = MIMEText (Message) msg ​​[' subject '] =' ['From'] = '[' to ''] [msg] = To_addr server = smtplib.SMTP ('myhost', 465) server ehoe () server.starttls () server.ehlo () server.login (login, password) server.sendmail (from_addr, to_addr, msg.as_string ()) Server.close () if __name __ == "__ main__": send_email ('test', 'this is a test email', 'myemailaddress', 'myemailaddress')  

2) Excel has an option to save a sheet as HTML. While doing so, I copy and paste the HTML source and email it as an attachment. Unfortunately, the colored text did not transfer whether anyone knows a better way of using Python to send the embedded Excel sheet in an email?

Thank you for your help!

More information is needed to determine the actual error. To achieve this, turn on debug logging for the smtplib module, you can do it by adding the following line before ehlo ().

  server.set_debuglevel (True)  

If my host school is a mail server, then the problem is most likely to be on the school mail server port 465 Not listening. If my hosts are Google's mail servers, then port 465 (SMTPS) is being blocked by the school network.

Research how non-text files and content are included in e-mail (i.e. MIME attachments). If you want to attach html to e-mail, but if the intent is to send the excel spreadsheet only then attach the spreadsheet - there is no need to convert it to HTML. To do this, there is a stack overflow post on the code:


Comments