Tuesday 9 February 2010

EWS Managed API through a Proxy Server

So I have been doing a bit more EWS stuff recently and part of that was to access an exchange server on the internet from behind a web proxy server. This threw up an error which had me a bit annoyed and after a fair bit of searching the web for an answer I found the following

The upshot being:-
  • You cannot specify a proxy server/credentials on a service by service basis - BAD TIMES
  • You CAN tell your application to use the default credentials for any proxy server it encounters while trying to make a request.. The answer lies in the following bit of code
C#

WebRequest.DefaultWebProxy.Credentials = System.Net.CredentialCache.DefaultCredentials;

For VB.NET, just remove the semicolon at the end of the line and place it above where you initialise your Exchange connector. Worked a treat for me ;-)

All credit to Mr David Claux for finding this one....

http://social.technet.microsoft.com/Forums/en/exchangesvrdevelopment/thread/6f3655d9-fdf4-4779-b1f3-afe78621b093