Link to home
Start Free TrialLog in
Avatar of TomPreen
TomPreen

asked on

Outlook Automation OLE Error

In attempting automation of Outlook 2010 'CreateObject('OutLook.Application') I get OLE error 0800401ea: Moniker cannot open file.
Avatar of Pavel Celba
Pavel Celba
Flag of Czechia image

1. You should tell what is the calling program.
2. You should try the calling program with elevated rights (Run as Administrator)

Are you sure the Outlook is installed locally (not Click-To-Run installation)?  Are you sure Office 365 was not used on the same computer? Do other Office 2010 applications work correctly? Are you able to invoke them via OLE Automation?
Avatar of TomPreen
TomPreen

ASKER

Calling program is Visual FoxPro 9.
Running as administrator returns OLE error 0x80080005 : server execution failed.

Run from a single user PC.

Office 365 has never been used

Incoming mail server is pop.gmail.com
outgoing mail server is smtp.gmail.com

I regularly code automation for Excel and Word with no issues
I've added FoxPro topic to this question.

OK, the latest error in VFP 9 admin mode appears on my computer, as well. So we can ignore it for now.

I am using Outlook ver. 16 (from Office 365 installed locally). Outlook or Office 2010 was installed earlier on the same computer but some negative interferences started in conjunction with my company Office 365 account... So I've reinstalled everything to the latest 365 version.

The status is following:
CREATEOBJECT('OutLook.Application')  works well for me.
GETOBJECT('Outlook.Application')  returns the 'Moniker cannot open the file' error…

Everything points to the way how the Outlook is installed and registered in Windows Registry and then accessed... Mail servers setup in Outlook should not be important at this point.

Unfortunately, nobody is able to tell what exactly to do to make it working for you.

So you must start your own investigation.
1. Open Registry editor and look for all occurrences of Outlook.Application string. Review all the keys and values which are "around". If several values point to a different versions of outlook (Outlook.Application.12, Outlook.Application.11, etc.) then try CREATEOBJECT with all these specific versions.
2. Look whether Windows logs contain some sign of the Moniker error (mine don't)
3. Execute Process Monitor and check what Registry keys are accessed when you issue CREATEOBJECT in VFP9 (CREATEOBJECT and GETOBJECT behaves rather differently for me)
4. Look at these keys in Windows Registry. They represent OLE Server for Outlook. If they don't exist then it means Outlook is not installed/registered correctly. Remember VFP looks for these keys at a few different places in Registry.

CREATEOBJECT call also checks/creates a file in Windows\Registration folder which I have no clue about...

Reading the above it seems the easiest attempt should be the Outlook 2010 reinstallation...

Of course to test the Outlook OLE Automation from a different calling program, e.g. VB6 (which is still supported by MSFT) or C# is another attempt you could give a try.
I have found that if I run VFP where Outlook is not running. CreateObject works.

It also works if I open Outlook by running as administrator and I also run VFP by running as Administrator.
Interesting…

Please try GETOBJECT('C:\Program Files\Microsoft Office\root\Office16\OUTLOOK.EXE', 'OutLook.Application')

It should return object reference of the running Outlook (use appropriate path to your EXE).
This returns OLE error 0x80080005 : server execution failed.

As with createobject, getobject only works where VFP and Outlook are opened with run as Administrator
This could mean insufficient access rights for user running VFP but I am not able to say what rights are missing.
This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.