Added bat file to source correct venv and run script. Reorganized db connection stuff and added check to create db/tables if they don't exist. Uncommented email section and set mark_sent method to only be called if not testing.
This commit is contained in:
14
sendEmail.py
14
sendEmail.py
@@ -191,13 +191,13 @@ def send_email(test, record):
|
||||
|
||||
msg.add_header('Content-Type', 'text/html')
|
||||
msg.attach(bodyHTML)
|
||||
# try:
|
||||
# with smtplib.SMTP(smtp_server, port, timeout=120) as server:
|
||||
# # server.sendmail(msg['From'], msg['To'] + ',' + msg['Cc'] + ',' + msg['Bcc'], msg.as_string())
|
||||
# server.send_message(msg)
|
||||
# except Exception as e:
|
||||
# print(e)
|
||||
if test is True:
|
||||
try:
|
||||
with smtplib.SMTP(smtp_server, port, timeout=120) as server:
|
||||
# server.sendmail(msg['From'], msg['To'] + ',' + msg['Cc'] + ',' + msg['Bcc'], msg.as_string())
|
||||
server.send_message(msg)
|
||||
except Exception as e:
|
||||
print(e)
|
||||
if test is False:
|
||||
InvoiceDatabase.mark_sent(InvoiceID, InvoiceDate)
|
||||
sent_orders.append(OrderNumber)
|
||||
print(sent_orders)
|
||||
|
||||
Reference in New Issue
Block a user