Automate Outlook 2013, 2010, 2007 without
"a program is trying to automatically send email"

Security Manager
for Microsoft® Outlook®

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

Outlook automation

With Outlook Security Manager you need just a few lines of code to eliminate alerts like a A program is trying to automatically send email on your behalf in Outlook 2013, 2010 and earlier versions of Outlook 2007 to 2000.

This example shows how to use Security Manager from an application that automates Outlook. You can also see the code samples (VBA, VB.NET, Delphi) to automate Microsoft Outlook. With this application you can send messages using Outlook as a "mail engine". In this project there is one form mimicking the Outlook Mail window with an Outlook Security check box.

Outlook Automation sample form

If you check this option, you disable Outlook Security and your application sends messages with no security warnings. Otherwise, you get one of these notorious security pop-up dialog boxes:

  • A program is trying to send an e-mail message on your behalf. If this is unexpected, click Deny and verify your antivirus software is up-to-date.
  • A program is trying to perform an action that may result in an e-mail message being sent on your behalf.

Microsoft Outlook security prompt

As well as in the example that disabls A program is trying to access e-mail addresses you have stored in Outlook alert, protected Outlook objects are used here. To disable Outlook Security, we use the DisableOOMWarnings property. But there is one peculiarity here. To use Outlook Security Manager inside an application interacting with Outlook you should connect it to Outlook.Application used by this application. To do this you can use the ConnectTo method of the SecurityManager class. For example:

Visual Basic .NET


Dim SecurityManager As New AddinExpress.Outlook.SecurityManager
SecurityManager.ConnectTo(outlookApp)
SecurityManager.DisableOOMWarnings = True
Try
  '... any action with protected objects such as contacts or items...
Finally
  ' In any case please remember
  ' to turn on Outlook Security
  ' after your code, since now
  ' it is very easy to switch it off! :-)
  SecurityManager.DisableOOMWarnings = False
End Try

Visual Basic 6 (VBA)


OlSecurityManager.ConnectTo OutlookApp
OlSecurityManager.DisableOOMWarnings = True
On Error Goto Finally
  '... any action with protected objects ...
Finally:
  OlSecurityManager.DisableOOMWarnings = False

Delphi


OlSecurityManager.ConnectTo(outlookApp);
OlSecurityManager.DisableOOMWarnings := True;
try
  //... any action with protected objects ...
finally
  OlSecurityManager.DisableOOMWarnings = False;
end;

Thus, if you want to disable Outlook security, use Outlook Security Manager and call the ConnectTo method before disabling Outlook Security.

Please, make sure that you turn Outlook Security on inside the "finally" section, because 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 showed in this example.

A program is trying to access e-mail <<

>> Deployment