EWS Authentication problem RRS feed

  • Question

  • Dears,

    Please find the code snippet as below which i used to connect to exchange server to read emails.

    ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010_SP2);

    ServicePointManager.ServerCertificateValidationCallback = Cert.CertificateValidationCallBack;

    service.Credentials = new NetworkCredential("user", "password", "domain");

    service.Url = new Uri(serverUrl);

    I was trying to connect to the same service based on the currently logged in User via SharePoint webpart.

    In MSDN (

    It was mentioned like below.

    // Connect by using the default credentials of the authenticated user.

    service.UseDefaultCredentials = true;

    Eventhough i used the above code entry i was unable to connect to the web service hence was getting the below error :

    The request failed. The remote server returned an error: (401) Unauthorized.

    how can solve the above mentioned problem?

    thanks in advance,


    • Edited by AmmarBIZ Wednesday, July 10, 2013 11:32 AM
    Wednesday, July 10, 2013 11:26 AM