Skip to content
Advertisement

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

enter image description here

How do i disable it

Advertisement

Answer

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_MACHINESOFTWAREMicrosoftOffice<x.0>OutlookSecurity normally
  • HKEY_LOCAL_MACHINESOFTWAREWow6432NodeMicrosoftOffice<x.0>OutlookSecurity 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.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement