Outlook and NT service

  • Thread starter Thread starter Nagina Eliav
  • Start date Start date
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
 
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
 
Back
Top