none
Setting credentials for Exchange Service in Outlook Add-ins RRS feed

  • Question

  • I have method to convert the Entry Id to EWS it.

    For calling the exchange service , i need to set the credentials.

    If i use the UseDefaultCredentials method on ExchangeService, it will be using the windows logged in user credentials.

    But i want to use the credentials that has been given in outlook since , we have a case where windows logged in credentials may not be the same as Outlook user. How to acheive this? is there a way to bind the service with outlook logged in credentials instead of windows login credentials. Code snippet given below.

     public string ConvertHexEntryIdToEwsId(string sID, string strSMTPAdd)
           {
               ExchangeVersion exchVersion = ExchangeVersion.Exchange2010;
               ExchangeService service = new ExchangeService(exchVersion);
               service.UseDefaultCredentials = true;    
               service.Url = new Uri(string.Format("https://{0}/EWS/Exchange.asmx",ConfigurationManager.AppSettings["ExchangeIP"]));
               string uniqueId = string.Empty;
               try
               {
                   AlternateId objAltID = new AlternateId();
                   objAltID.Format = IdFormat.HexEntryId;
                   objAltID.Mailbox = strSMTPAdd;
                   objAltID.UniqueId = sID;

                   AlternateIdBase objAltIDBase = service.ConvertId(objAltID, IdFormat.EwsId);
                   AlternateId objAltIDResp = (AlternateId)objAltIDBase;
                   uniqueId = objAltIDResp.UniqueId;
               }
               catch
               {
                   throw;
               }
                       return uniqueId;
           }


    Partha


    Partha

    Friday, October 17, 2014 10:44 AM