How do I interface with Exchange Server using C#?

Biff MaGriff picture Biff MaGriff · Feb 7, 2011 · Viewed 19.3k times · Source

We had a bit of a snafu on our e-mail server and the permissions went out of whack on our users e-mail folders.

Unfortunately our users are all on Outlook Web Access and do not have access to change the permissions on their e-mail folders.

What I've been tasked with is to expose the ability to change the permissions on exchange e-mail folders. My plan is to somehow interface with Exchange and put the relevant information in an ASP.Net webpage.

I see that there is an Exchange Web Services dll however I'm not sure if that is enabled on our installation. Is there another way to communicate with Exchange? Preferably using C#? Is it easy to turn on Web Services if it is off? How can I check if it is on?

Regards,

Edit : I tried connecting through EWS however I'm getting Error 102 (net::ERR_CONNECTION_REFUSED): Unknown error. This may be because I do not have permissions or the service isn't turned on. I'm going to look into that. Thanks for the suggestions.

Ok, it looks like I had the wrong URI. I'm now getting an "Exchange Server doesn't support the requested version." (I'm just trying to send a test e-mail)

Answer

Hans Olsson picture Hans Olsson · Feb 7, 2011

The best way to check if it's up an running and everything working fine would probably be to create a simple sample app as described here: Creating an Exchange Web Services Client Application

As far as I know, this is the best way of accessing Exchange from C#. I think the old way was CDO but that's not supported by Microsoft for .Net I think.