2

On Windows 7 32 / 64 bit with UAC enabled and Outlook 2010 running I receive a ComFailException when attempting to create new ActiveXComponent via:

ActiveXComponent axOutlook = new ActiveXComponent("Outlook.Application");

Has anyone found a source workaround with this issue or has this issue been corrected with later versions of JACOB? Currently, we are telling our customers to close Outlook before emailing their reports.

user3826668
  • 145
  • 1
  • 2
  • 8

2 Answers2

1

The error is CO_E_SERVER_EXEC_FAILURE.

The error is raised when your code and Outlook are running in different security contexts.

Dmitry Streblechenko
  • 62,942
  • 4
  • 53
  • 78
  • Because Outlook is already running, I am unable to open a new instance of Outlook temporarily and then close once I am finished sending the email? Is this a bug or a design of the JACOB libraries? – user3826668 Jul 22 '14 at 19:46
  • No, just the way Outlook works - it is a singleton, there is only one instance running at any time. You need to make sure both apps are in the same security context. Is either app running with elevated privileges (Run as Administrator)? – Dmitry Streblechenko Jul 22 '14 at 21:10
  • Both are running as the local user and at the same privileges. Could JACOB latch onto the existing Outlook singleton and perform any operations there? I have been looking for something like that online and coming up empty handed. – user3826668 Jul 22 '14 at 21:25
  • If Outlook is already running, you will always get a pointer to that running instance - that is what being singleton means. – Dmitry Streblechenko Jul 22 '14 at 21:41
  • I guess the new question is can JACOB attach to the singleton and how? Through my online searching, I have not found any solutions to the question. – user3826668 Jul 23 '14 at 12:07
  • This has nothing to do with JACOB - it does not need to know anything about singletons. it is straight COM, a standard CoCreateInstance will return a pointer to the Outlook.Application object of the already running instance of Outlook. But since Outlook and your app are running in different security contexts, you get an error. Again, nothing to do with JACOB. You will get the same error in C# or any other language. – Dmitry Streblechenko Jul 23 '14 at 20:14
  • The real question is how does your app run? Is it a standard GUI app? Service? Or something else? – Dmitry Streblechenko Jul 23 '14 at 20:15
  • I am starting to get into new territory with Java so I will do my best to answer your questions. We are executing a GUI app on the JVM using JRE 1.6 Build 30. It is installed using an installer but at the time of installation, I don't know what the user rights are. Developers have the UAC (user account controls) turned off so we can co-create an instance of Outlook. Customers will more than likely not have UAC turned off. I am going to investigate what happens during installation. – user3826668 Jul 24 '14 at 19:31
1

I got this error when running Jacob code in Eclipse under Windows 7 ( as administrator), and outlook was running with normal privileges. When I changed privileges for Outlook ( run as administrator), it worked.

Levijatanu
  • 371
  • 2
  • 17