Reputation: 99
I'm reading messages from an outlook inbox and am opening outlook with the following command in python 3.6:
outlook=win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI")
The problem that I'm having is that whenever I do this, the user then has to manually got to their outlook and allow an outside program to read messages. I'm wondering if there's a way to get around this problem.
It seems that using:
outlook=win32com.client.DispatchEx("Outlook.Application")
could help by opening outlook in a different account that doesn't require the user's allowance, but I can't find documentation on what that command actually does.
After opening outlook I want to be able to use it in the following way:
# Open a msg file using outlook.
msg = outlook.OpenSharedItem(abs_path)
# Extract text from the message.
all_text = "Subject:\n" + msg.Subject + "\n\n"
all_text += "Body:\n" + msg.Body
How should I try to open outlook/ rewrite my code in a way that doesn't require the user to manually allow my program access? Also, side note, is there a good way to prevent the processes I do in outlook from opening any windows on my computer?
Upvotes: 1
Views: 666
Reputation: 66341
In a nutshell, installing an up-to-date antivirus app would get rid of the security prompts. If you cannot control the environment, there are ways to work around them programmatically. See http://www.outlookcode.com/article.aspx?id=52 for more details.
Upvotes: 1