Outlook logon from a Windows Service

  • Thread starter Thread starter W Akthar
  • Start date Start date
W

W Akthar

Hi All,

I have written a windows service which runs a small
windows application. This windows application queries a
sql server database and depending on these results, sets
appointments in outlook.

When I run the windows application outside the service it
works fine as designed, but when it is launched from a
windows service I get an error message

The server is not available. Contact your administrator
if this condition persists.

when trying to logon using the following code

oNS.Logon(profile, password, false, true);

Any ideas please???
 
W Akthar,

Chances are that you need to allow the service to interact with the
desktop (which means that you need an interactive login session as well).
On top of that, Outlook has a whole bunch of security dialogs that pop up
when you try to do something that the user isn't aware of, so I would expect
those to show up as well.

Generally speaking, you should not be running windows applications from
within services. Rather, you should find another way to set the data in
outlook.

Hope this helps.
 
W Akthar said:
Hi All,

I have written a windows service which runs a small
windows application. This windows application queries a
sql server database and depending on these results, sets
appointments in outlook.

When I run the windows application outside the service it
works fine as designed, but when it is launched from a
windows service I get an error message

The server is not available. Contact your administrator
if this condition persists.

when trying to logon using the following code

oNS.Logon(profile, password, false, true);

Any ideas please???
Ok, you found-out that you couldn't access outlook from within a service, so
now you try to launch a windows application (using oulook automation
objects) from a service. This won't help you either as this application runs
in the same security/user context as the service, that means that the
'profile' which is stored in HCU, is not accessible by the service.
As I suggested before don't try to use Office application in the context of
a non-interactive user. Why not simply launch the windows application using
a logon script?

Willy.
 
Back
Top