Allow Programmatic Access to Outlook

The MS Outlook library functions allow a robotic solution to read information from the Outlook application installed on the machine on which the robotic solution will be run.

However, Outlook security settings may block access to those functions. Depending on the version of Outlook installed, the message below might be displayed.

In other cases, the message will not be displayed but the functions will not be able to retrieve the information requested.

To enable the MS Outlook library functions to work as intended, you must enable programmatic access to Outlook on every machine on which the robotic solution will be run. There are two ways to do this:

  • By changing the security settings within Outlook Trust Center

  • By editing the registry

Depending on the corporate group policy applied, these options may not be available in which case it is necessary to automate the clicking of the Allow button in the message window displayed above.

Enable Programmatic Access through Outlook Trust Center

The simplest method to allow programmatic access to Outlook is through the Outlook Trust Center.

  1. Close Outlook if currently open.

  2. Run Outlook as an administrator.

  3. Select File > Options > Trust Center.

  4. Click Trust Center Settings.

  5. Select Never warn me about suspicious activity. If this option is not available, try the alternative approach below.

  6. Click OK.

Enable Programmatic Access through the Registry

When corporate group policy prevents changing settings in the Outlook Trust Center, the alternative is to enable programmatic access to Outlook through the registry.

  1. Ensure that you have Administrator rights.

  2. Save the following text in a file with an extension .reg:

    Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\<Build Number>\Outlook\Security] "ObjectModelGuard"=dword:00000002

    Replace <Build Number> in the text above with the appropriate code for the version of Outlook in use as per the table below.

    Version

    Build Number

    2007 12.0
    2010 14.0
    2013 15.0
    2016 16.0
  3. Double-click the .reg file to add the entry to HKEY_LOCAL_MACHINE.

  4. Similarly, add the following to HKEY_CURRENT_USER:

    Windows Registry Editor Version 5.00 [HKEY_CURRENT_USER\Software\Policies\Microsoft\office\<Build Number>\Outlook\Security] "PromptOOMSend"=dword:00000002
    "AdminSecurityMode"=dword:00000003 "promptoomaddressinformationaccess"=dword:00000002 "promptoomaddressbookaccess"=dword:00000002
    

    Replace <Build Number> in the text above with the appropriate code for the version of Outlook in use as per the table shown previously.

Automate Enabling Programmatic Access to Outlook

If it is not possible, due to corporate group policy, to change settings in the Outlook Trust Center and through the registry, it is necessary to automate the response to the message below which is displayed when an MS Outlook library function attempts to retrieve information from Outlook.

The procedure for doing so is outline below.

  1. Capture the Allow button, the checkbox, and the drop-down list in this window as screen elements.

  2. Set up an event handler that will be activated when this window is displayed.

  3. When activated, the event handler should:

    1. Check the checkbox.

    2. Set the drop-down to 10 minutes.

    3. Click the Allow button.