I wrote a python script that uses win32com.client.Dispatch("Outlook.Application") to send automated emails through outlook.
If I run the script myself everything works perfectly fine. But if I run it through Window's task scheduler it doesn't send the emails.
Just to check if I am running the script properly I made the script output a random text file and that works but email doesn't. Why?
My similar issue has been cleared up. I used task scheduler to call a python script (via batch file) that has the pywin32com module. The python code opens excel and calls a macro. It will run fine from python, cmd and the batch file, but wasn't working when ran through task scheduler. It traced back to errors like:
"EnsureDispatch disp = win32com.client.Dispatch(prog_id)"
As noted on this thread, I changed the option to "Run only when user is logged on" and it ran successfully!
The only drawback is that I schedule the task for a time that I'm away from the computer. I suppose I just have to not log off and hope that the cpu doesn't go into sleep mode, but that's not really a big deal in this case.
Sending automated email using Pywin32 & outlook in a python script works but when automating it through windows task scheduler doesn't work