Background: I am on Windows 7 and am trying to automate some email-related list updates. I have a python script that pulls-in emails, downloads certain attachments and sends me back a new email with some results. This all works great when I run the code manually:
- via Windows command prompt.
- Within my IDE.
- Wrapping it in a .bat file and dbl-clicking the bat file.
To be clear here: When executed in any of the above ways, the script successfully checks emails, parses the attachments and sends an email to myself containing the desired information.
Problem: When I try to set-up a scheduled task (I have admin privileges) on my local PC to run the .bat file, the script terminates at the following lines:
#Grab an outlook COM
outlook_app = win32com.client.Dispatch("Outlook.Application")
outlook = outlook_app.GetNamespace("MAPI")
I know this because I have the script printing logs to a separate text file. The task scheduler executes the batch file, I see logs being written to the text file for earlier steps, but it fails at these two lines.
Is there something I am missing about win32com
and the task scheduler?