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.application import MIMEApplication
|
||||||
from email.mime.multipart import MIMEMultipart
|
from email.mime.multipart import MIMEMultipart
|
||||||
from smtplib import SMTP
|
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 = configparser.ConfigParser()
|
||||||
config.read("c:/Users/Seb/pythonmodule/Module1/testenv.txt")
|
config.read("c:/Users/Seb/pythonmodule/Module1/testenv.txt")
|
||||||
emailp = config.get("config","test")
|
emailp = config.get("config","test")
|
||||||
|
|
@ -27,18 +26,8 @@ print(data2.tail(1))
|
||||||
data2.head()
|
data2.head()
|
||||||
|
|
||||||
|
|
||||||
Body_of_Email = """\
|
recipients = ["sebastien.trudel@pirolian.com"]
|
||||||
Subject: Daily Stock Report
|
emaillist = [elem.strip().split(',') for elem in recipients]
|
||||||
|
|
||||||
Daily stock report:
|
|
||||||
|
|
||||||
""" + data2.to_html() + """\
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Sincerely,
|
|
||||||
Your Computer"""
|
|
||||||
|
|
||||||
msg = MIMEMultipart()
|
msg = MIMEMultipart()
|
||||||
msg["Subject"] = "Daily Stock report"
|
msg["Subject"] = "Daily Stock report"
|
||||||
msg["From"] = "strudel@pirolian.com"
|
msg["From"] = "strudel@pirolian.com"
|
||||||
|
|
@ -56,15 +45,12 @@ html = """\
|
||||||
part1 = MIMEText(html, "html")
|
part1 = MIMEText(html, "html")
|
||||||
msg.attach(part1)
|
msg.attach(part1)
|
||||||
|
|
||||||
server = smtplib.SMTP("smtppro.zoho.com", 465)
|
|
||||||
server.sendmail(msg["From"], emaillist , msg.as_string())
|
|
||||||
|
|
||||||
context = ssl.create_default_context()
|
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
|
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:
|
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.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