Updated send by email
This commit is contained in:
parent
fd6bf64942
commit
e7edab7977
26
GetDaily.py
26
GetDaily.py
|
|
@ -9,9 +9,8 @@ from email.mime.text import MIMEText
|
|||
from email.mime.application import MIMEApplication
|
||||
from email.mime.multipart import MIMEMultipart
|
||||
from smtplib import SMTP
|
||||
#print(os.environ['your_env_variable'])
|
||||
#sys.path.append(os.path.abspath("c:/users/seb"))
|
||||
#import pythonmodule.Module1.testenv
|
||||
|
||||
|
||||
config = configparser.ConfigParser()
|
||||
config.read("c:/Users/Seb/pythonmodule/Module1/testenv.txt")
|
||||
emailp = config.get("config","test")
|
||||
|
|
@ -27,18 +26,8 @@ print(data2.tail(1))
|
|||
data2.head()
|
||||
|
||||
|
||||
Body_of_Email = """\
|
||||
Subject: Daily Stock Report
|
||||
|
||||
Daily stock report:
|
||||
|
||||
""" + data2.to_html() + """\
|
||||
|
||||
|
||||
|
||||
Sincerely,
|
||||
Your Computer"""
|
||||
|
||||
recipients = ["sebastien.trudel@pirolian.com"]
|
||||
emaillist = [elem.strip().split(',') for elem in recipients]
|
||||
msg = MIMEMultipart()
|
||||
msg["Subject"] = "Daily Stock report"
|
||||
msg["From"] = "strudel@pirolian.com"
|
||||
|
|
@ -56,15 +45,12 @@ html = """\
|
|||
part1 = MIMEText(html, "html")
|
||||
msg.attach(part1)
|
||||
|
||||
server = smtplib.SMTP("smtppro.zoho.com", 465)
|
||||
server.sendmail(msg["From"], emaillist , msg.as_string())
|
||||
|
||||
context = ssl.create_default_context()
|
||||
Email_Port = 465 # If you are not using a gmail account, you will need to look up the port for your specific email host
|
||||
with smtplib.SMTP_SSL("smtppro.zoho.com", Email_Port, context=context) as server:
|
||||
server.login("strudel@pirolian.com", emailp) # This statement is of the form: server.login(<Your email>, "Your email password")
|
||||
server.sendmail("strudel@pirolian.com", "sebastien.trudel@pirolian.com", Body_of_Email) # This statement is of the form: server.sendmail(<Your email>, <Email receiving message>, Body_of_Email)
|
||||
|
||||
# server.sendmail("strudel@pirolian.com", "sebastien.trudel@pirolian.com", Body_of_Email) # This statement is of the form: server.sendmail(<Your email>, <Email receiving message>, Body_of_Email)
|
||||
server.sendmail(msg["From"], emaillist, msg.as_string()) # This statement is of the form: server.sendmail(<Your email>, <Email receiving message>, Body_of_Email)
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue