Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Outlook Automation Error 1426 OLE-Errorcode 0x80080005 - Server execution failed

Status
Not open for further replies.

Tom Borgmann

Programmer
Feb 9, 2017
103
DE
Hi guys,

currently VFP reacts different with identical code, depending on placing it in a prg or within a class method.

the prg version runs fine and in a split second it opens the outlook mail window, either if Outlook is running or not.

However, the same code within a class fires error 1426

I also changed the code from LOCAL to class properties and even PUBLIC, but from within the classlib it always comes up with 1426 when trying to instanciate Outlook. I also switched from CREATEOBJECT to CREATEOBJECTEX, but to no avail. I should mention, that CREATEOBJECTEX within the prg is working fine, too.

Anything about that error I found on the web was based on patching problems. But this isn't the case here because I'm testing both version at the time.

Here comes the code snippet and hopefully someone can give me a hint on this.

TIA

Code:
TRY 
	LOCAL loOutlook   AS Outlook.Application
	LOCAL loNameSpace AS Outlook.NameSpace 
	LOCAL loMailItem  AS Outlook.MailItem
	 
	#DEFINE olMailItem   0
	
	* // This is where the error fires!!!!!!
	* // It lasts ~15-30 secs, until the app falls into the CATCH TO blog
*	loOutlook   = CREATEOBJECT( [Outlook.Application] )
	loOutlook   = CREATEOBJECTEX( [Outlook.Application] , [] , [] )

	loNameSpace = loOutlook.GetNamespace( [MAPI] )
	loNameSpace.Logon
	loMailItem  = loOutlook.CreateItem( olMailItem )
	 
	WITH loMailItem
		.Recipients.Add( [EMAIL@YOU.NET] )
		.Subject = [place some text here]
		.Body    = [place some messagetext there]
		.Display
	ENDWITH

	loMailItem	= .NULL.
	loNameSpace	= .NULL.
	loOutlook	= .NULL.
CATCH TO ex
	SET STEP ON 
	llOK = .F.
ENDTRY

-Tom
 
Hello Tom,

no idea, I can't even imagine what the difference would be between running that within a PRG or class. Even if PRG runs in the main datasession and class code in another, the Outlook process has nothing to do with data sessions. You might have different datasession specific settings.

In itself, CREATEOBJECT Or EX are starting a separate outlook process, no more no less, I don't see how PRG vs class method context would make a difference. This is only working or failing with correct registration. There can't be a core problem if it works the one but not the other way, but I also can't imagine how the VFP CREATEOBJECT() command would act different called from different contexts.

The only somewhat similar thing I remember was the license limitation to use a certain OLE class within the form as container and not outside, IIRC that was about the Winsock OCX class mswinsock.winsock. That hints on some conditional checks made by the OLE server instaintiation. So it would also likely be interesting which Outlook version this is about and be worth a ticket at Microsoft - about Outlook rather than about VFP, of course.

Bye, Olaf.

Olaf Doschke Software Engineering
 
Just another thing I just found out:

When closing Outlook, the code from the classlib is doing fine O^O

I know about Dave Croziers 7 year old answer on [URL unfurl="true"]https://profox.leafe.narkive.com/L1Eafn3U/automating-outlook-2007[/url], but I didn't expext, that running a prg is so different to instatiating an object to do the same, as both is done in design time.....


-Tom
 
Tom,

It may be not related to your problem, but using [] for the definition of string literals is an open door for issues that may be quite hard to trace.

For instance, what do you think would be output for this code snippet?

Code:
#DEFINE OUTLOOK	Lookout

? "Outlook.Application"
? 'Outlook.Application'
? [Outlook.Application]

Not knowing anything more of the exact conditions of your environment, and taking into full consideration the situation you reported, as soon as I looked into your code that alarm bell started to ring. At least, it could explain the differences in the behavior.

I would begin by changing
Code:
	loOutlook   = CREATEOBJECT( [Outlook.Application] )
to
Code:
	loOutlook   = CREATEOBJECT( "Outlook.Application" )
 
olMailItem or loMailItem? You have both

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
What does AERROR() tell you after the failure? For OLE errors, it provides additional info.

Tamar
 
@atlopes
you definetely get a point here. In case of using DEFINEs, square brackets can obviously be a pain in the a$$.
In this case it won't intefere, though. But I'll keep your tipp in mind when I make use of DEFINE in the future! ;)

@Mike
loMailItem is the object reference
olMailItem is the DEFINE value 0

@Tamar
I just put an AERROR in the code, right before the SET STEP ON and it gives exactly the same infos as the CATCH TO ex object.


I'll give you feedback as soon as I have tested the compiled App. However, this might last a few days as I am currently in the middle of the process.

TY @all for your inputs :)


-Tom
 
Hi @all :)
here comes the promised news [smile]

Within the compiled .exe everything is running fine. Outlook may be running or not, the Mailto window will popup at once without any problems.

However, even starting the exe with RUN /N from VFPs command window will end up with an error 1426. Only starting the app outside the VFP context doesn't throw this error. So obviously it must have something to do with rights and app context.

So, all in all...it's weird, but I can (or have to) live with it [smile]


-Tom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top