I'm very to new to this python and some other technologies, can someone suggest better ideas here very appreciated!
I have two python scripts when i ran both scripts, i'm able to create log files with timestamp every time i ran
so that log files i need to send outlook mail automatically once my python scripts completed
once i ran scripts when it completes i need to send outlook mail with attachment of log files automatically
i heard about smptplib library to send mails, but i need to send mail with log files once task completed
please suggest your ideas here
lets assume below example division.py file
import logging
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
f = logging.Formatter('%(asctime)s,%(msecs)d %(name)s %(levelname)s %(message)s')
now = datetime.datetime.now()
filename = now.strftime('new_logfile_%Y-%m-%d--%H-%M-%S.log')
fh = logging.FileHandler(filename)
fh.setFormatter(f)
logger.addHandler(fh)
a = 5
b = 0
try:
c = a / b
logger.info(c)
except Exception as e:
logger.exception("Exception occurred")
when i ran above .py file it creates log file, so i need to add mail functionality in same program so when i ran program once it is completed i need to send log files to mail automatically