danalu
6 years agoContributor
Python - Send Email by OutLook 2010 failed when outlook is closed
Hi ,
i want to use below code to send report by out look after test done.
def send_to_mail(test_result):
fmt = '%Y-%m-%d'
report_time = time.strftime(fmt)
outlook = Sys.OleObject["Outlook.Application"]
mail = outlook.CreateItem(0)
mail.To = test_result[0]['MailTo']
test_app = test_result[0]['Name']
mail.Subject = 'TestComplete - '+ test_app + ' Auto Test Report - ' + report_time
mail.HTMLBody = test_result[1]
mail.Send()
it works if my outlook is open in desktop, but fail with error "Operation Failed" if outlook is closed.
Can anyone help on this?? because we need run cases from remote PC which install outlook, but would not like it opened.