Solved

Using OLE Servers under NT Service

Posted on 2002-04-01
10
285 Views
Last Modified: 2010-04-04
I want to write an NT Service that uses the TOutlookApplication server (Delphi 6), to watch for incoming emails.

I wrote a simple test app that hooks the NewMail event, and that worked fine.

No when I tried to convert this to an NT Service I get an error when trying to connect.

The error message was ...
"Service failed on execute: CoInitialize has not been called."

I found a reference that suggested manually calling CoInitialize, but this has just changed the error...
"Service failed on execute: Server execution failed."

Is there a limitation which prevents me from doing what I want to do?

Can you suggest an alternative?
0
Comment
Question by:Hamlet081299
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
10 Comments
 

Expert Comment

by:classics
ID: 6911963
Does this sort of service need to run in a particular user context?
0
 
LVL 5

Author Comment

by:Hamlet081299
ID: 6911975
Maybe.  I've tried it various ways but still have problems.  

In some cases the service gets "stuck" in a "Starting" state, and the only way I can kill it then is to restart my machine.
0
 
LVL 12

Expert Comment

by:Lee_Nover
ID: 6912512
when do you execute your startup code ?
as the help sais you should minimize the execution code in the startup of the service (OnStart event)
also any errors occuring in the startup event will result in failing to startup the service
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 5

Author Comment

by:Hamlet081299
ID: 6912529
I have no code in the OnStart I initialize things at the start of the OnExcute.  Maybe that's the problem?
0
 
LVL 12

Expert Comment

by:Lee_Nover
ID: 6913943
nope it's not
while the code in the OnExecute event is executed the Service runs
when the code exits the service stops
so you should do some loop in there like : InitStuff; while not Stopped do begin ... end; FinalizeStuff;
0
 
LVL 5

Author Comment

by:Hamlet081299
ID: 6914246
yep. That's pretty much what I do.

I've come to the point now where I'm resigned to just writing it as a regular app and putting it in the tray.

With that in mind I have decided to delete this question.
0
 
LVL 1

Accepted Solution

by:
Moondancer earned 0 total points
ID: 6979131
200 points refunded, this question moved to the PAQ at zero points rather than deleting it, since it "may" help others.

Moondancer - EE Moderator
0
 
LVL 6

Expert Comment

by:PHD
ID: 7281121
Hello,
I have the same problem do you find the solution ?

thanks

Philippe
0
 
LVL 5

Author Comment

by:Hamlet081299
ID: 7296321
I never did find a solution that used this technique.  

What I did do that worked, was to write the whole thing using Extended MAPI, but that's a whole new kettle of fish.

That was a while ago now, and it was pretty complex to get it all going ... to complex to easily comment on here.

If you want to go down this path I would suggest you get some good references on Extended MAPI.  I ended up hunting around through various components and things, but in the end had to write most of it myself.

Good luck.
0
 

Expert Comment

by:SaPHeRMaXX
ID: 7587936
Well, I do not find a way to contact you directly. I can only be hopeful that you'll find my request. I am looking for exactyl what you already did: hook into the MAPI _NewMail event to be able to react to new mails on an exchange server. Could you please try to contact me or post the source code??

Yours, Arne   (arnebaier@web.de)
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

737 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question