Avoid 'A program is trying to access
e-mail addresses you have stored in Outlook'

Security Manager
for Microsoft® Outlook®

Add-in Express Home > Outlook Security Manager > Online Guide > A program is trying to access e-mail

When are Outlook security warnings fired?

If you have ever developed add-ins or applications that interact with Microsoft Outlook, then no doubt you have run into "A program is trying to access e-mail addresses" security warning. Outlook Security Manager allows you to get rid of this warning with just a few lines of code and easily access email addresses from the Address book (supports VBA, VB .NET, C#, C++, Visual Basic 6, Delphi, Word MailMerge, etc.)

This example is an Outlook COM add-in based on Add-in Express for Microsoft Office and .net; accordingly, to run the sample, you must have Add-in Express installed. You can also download this example. Please note that all the examples use Outlook 2000 interop assembly.

Microsoft claims that COM add-ins can be trusted and this completely solves the security problem. Aha! We have tried it many times, but trusted add-ins work in Outlook 2003 only. That is why this example will be useful if you develop add-ins for Outlook 2000 - 2016.

Add-in sample that disables Outlook Security

This add-in adds to the Explorer window a new command bar with three buttons. The first button is a switcher that disables or enables Outlook Security, the second button shows Outlook contacts, and the third shows the details of the current e-mail message. When Outlook Security is enabled (by default), you get one of the following security warnings when clicking on the Contact or Details buttons:

  • A program is trying to access e-mail address information stored in Outlook. If this is unexpected, click Deny and verify your antivirus software is up-to-date.
  • A program is trying to access e-mail addresses you have stored in Outlook. Do you want to allow this?

If you disable Outlook Security, you will never see this irritating alert message Outlook 2000, XP or in Outlook 2003.

A program is trying to access e-mail addresses you have stored in Outlook

In Outlook 2007, 2010, 2013 or Outlook 2016, this dialog won't pop up either.

A program is trying to access email address information

How to disable Outlook Security pop-ups

Open the add-in solution in the Visual Studio IDE and then open the add-in module. You see the SecurityManager component, an instance of the OlSecurityManager class, added to the add-in module. In the DoEnumContatcs and DoGetInfo methods of the add-in module, you can find the following lines:

C# code example

				if (btnOnOff.State == AddinExpress.MSO.ADXMsoButtonState.adxMsoButtonDown)
				 SecurityManager.DisableOOMWarnings = true;
				 //...some actions with protected Outlook objects...
				 if (btnOnOff.State == AddinExpress.MSO.ADXMsoButtonState.adxMsoButtonDown)
				 SecurityManager.DisableOOMWarnings = false;

The first "if" statement disables Outlook Security if the security button is down. The "finally" section enables Outlook Security. Between these lines you can place your code that uses protected Outlook objects (e.g. email addresses in our case).

That's all. Just remember that if you set the DisableOOMWarnings property of the SecurityManager class to True, it disables Outlook Security and allows using protected objects from the Outlook Object Model (OOM).

Also remember that you must turn the Outlook Security on inside the "finally" section. You should be aware that Outlook Security Manager can potentially open a door for unsafe content. To avoid this you must enable Outlook security within a protected finalization code after each elementary call of the protected objects as we have shown in this example.

This example illustrates how to disable Outlook Security when using protected Outlook objects. But you can disable Outlook Security when using protected CDO objects or protected Simple MAPI functions. Just use other properties of the SecurityManager class, namely DisableCDOWarnings and DisableSMAPIWarnings.

We will not comment on the whole code of this add-in to give you an opportunity to examine it yourself.

Terminology <<

>> A program is trying to automatically send e-mail