Click here to Skip to main content
16,021,226 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,
My little windows test application which reads email from my outlook works correctly.
The code only works if my outlook is open otherwise it gives a logon error.

Now I am trying to place it into a windows service so that it can be scheduled...
So using the same code, I have created a windows service to read my outlook...
I have deployed it onto server and the error it gives is as follows.
I have investigated and the error is on the point where it tries to logon to outlook.
Any suggestions please?
Thanks

C#
System.Runtime.InteropServices.COMException (0x80040111): The server is not available. Contact your administrator if this condition persists. at Microsoft.Office.Interop.Outlook.NameSpaceClass.Logon(Object Profile, Object Password, Object ShowDialog, Object NewSession) ...
Posted
Updated 8-Apr-16 9:52am
Comments
ZurdoDev 7-Nov-13 11:04am    
You would have to show the code where you are passing credentials to login to outlook. However, it says the server is not available so make sure the connection is correct.
arkiboys 8-Nov-13 12:16pm    
ns.Logon("domain\username", "pwd", false, true);

There are many manuals on this topic. For example, you can read this 3-part cycle of CodeProject articles:
Programming With Exchange Server 2007 (EWS) - Part 1[^] (Exchange architecture and the basics are explained here),
Programming With Exchange Server 2007 (EWS) - Part 2[^] (accessing items in a folder and searching them is explained here),
Programming with Exchange Server 2007 (EWS) - Part 3[^] (reading mail is explained here).

Good luck,
—SA
 
Share this answer
 
The problem is you're using Outlook Interop. Interop is NOT supported for Office applications from a non-interactive application, such as a Windows Service.

The service, unless you changed it, runs as Local System, which will not have any access to your Outlook at all.

This should not have been written as a Windows Service. For a "scheduled" application, you could have written this as a normal console application and setup the schedule to run it using Windows Scheduler. You can also set it up to run as you instead of as the system.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900