Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

how to disable outlook security pop-ups when sending emails via python

I have a problem I am trying to automate the sending of emails using win32 in python.
The problem s that every time when I run the code I get a security pop as shown below

How do i disable it

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Disclaimer: you should not be sending messages by automating a message software, EVER.

There are way better ways to send emails programatically:

  • smtplib, for sending through standard SMTP:
  • exchangelib, for sending using Exchange Web Services, for Microsoft 365 corporate inbox

But you’ve asked how to disable this security pop-up, and here is the answer, as explained in the Microsoft Outlook help website.

To disable this pop-up you should create a DWORD key named ObjectModelGuard in Windows registry. The folder will be one of:

  • HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office<x.0>\Outlook\Security normally
  • HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Office<x.0>\Outlook\Security if Outlook is running in 32-bit emulation from a 64-bit operating system (i.e. you are using a 32-bit build of Outlook in a 64-bit version of Windows).

You have to replace <x.0> with the specific version of Microsoft Office (16.0 = Office 2016, Office 2019, Office LTSC 2021, or Outlook for Microsoft 365, and 15.0 = Office 2013).

Set the key value to 2 to disable the warning, 0 for default behavior (only warns if an antivirus is not detected) or 1 to always warn.

If you need to, you could automate this behavior through Python, although you would require administrator rights to do so. Use winreg to access the Windows registry through Python.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading