Outlook and NT service

N

Nagina Eliav

Hello
I have problem to connect to Outlook from Nt Service

i am using following code in c#

Outlook.Application oApp=new Outlook.ApplicationClass();
Outlook._NameSpace oNameSpace = oApp.GetNamespace("MAPI");
MAPI.Session oSession = new MAPI.SessionClass();
Outlook.ContactItem oContact=null;
oSession.Logon(Missing.Value , Missing.Value, Missing.Value, true,
Missing.Value, Missing.Value, "server" + "\n" + "username" );

oNameSpace.Logon(oSession.Name ,Missing.Value ,Missing.Value ,true);

(Outlook.MAPIFolder )oContactsFolder =
(Outlook.MAPIFolder)oNameSpace.GetDefaultFolder(Outlook.OlDefaultFolders
.olFolderContacts);

this code successfully running in application
but as Nt service i got following error

Error description:
System.Runtime.InteropServices.COMException (0x84140111): The server is
not available. Contact your administrator if this condition persists.
at Outlook.NameSpaceClass.Logon(Object Profile, Object Password,
Object ShowDialog, Object NewSession)

Is anyone knows why this error happends when it runs as service?
thanks
Nagina
 
A

Arild Bakken

What account are you running the service under? Does it have sufficient
privileges and access rights to Outlook? Have you tried logging onto the
server as that account and run the code then?

Arild
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top