Mark Lugg
Mark Lugg

Reputation: 3

Using Interaction.CreateObject("Outlook.Application") with new version of Outlook does not work

I have a VB.Net application that emails via Outlook using Interaction.CreateObject("Outlook.Application"). This has been working fine until my client's IT department started pushing version 1.2024.111.100 (client version 20240119003.09) of Outlook to users' machines.

This code now gives the error "Unable to create the ActiveX component". Is there some fundamental difference in how the new version works? Is there a better approach?

I am not sure what to try at this point. I have been doing some research, but have not come upon any solutions yet.

Upvotes: 0

Views: 1645

Answers (2)

Dmitry Streblechenko
Dmitry Streblechenko

Reputation: 66286

The new web based Outlook (aka Monarch) has absolutely nothing in common with the desktop version of Outlook. There is no externally accessible API similar to the Outlook Object Model.

Switching back to the desktop version of Outlook (part of the Office suite) is your only option.

Keep in mind that Monarch is a replacement for Windows Mail and Windows Calendar, not the desktop version of Outlook, which is still fully supported.

Upvotes: 1

Eugene Astafiev
Eugene Astafiev

Reputation: 49455

First, try to get a running instance before creating a new one. For example, the following code connects to the running Application instance before creating a new one:

Set oApp = GetObject(, "Outlook.Application")    

If oApp Is Nothing Then
  Set oApp = CreateObject("Outlook.Application")
  oApp.GetNamespace("MAPI").GetDefaultFolder(6).Display
End If

See Determining whether an existing Outlook instance is open for more information.

Second, make sure that no Outlook processes are run already before trying to create a new Application instance in the code. If the process is launched under a different security context your code will not be able to automate Outlook and always got an error in the code. There is nothing that can be done in that case. The best what you could do is to check the list of running processes for outlook.exe entry and let users know that Outlook is already run and your application can't connect to it.

Upvotes: 0

Related Questions