ExchangeServiceBase.Credentials property

Gets or sets the credentials that are used to authenticate with Exchange Web Services (EWS).

Namespace:  Microsoft.Exchange.WebServices.Data
Assembly:  Microsoft.Exchange.WebServices (in Microsoft.Exchange.WebServices.dll)

public ExchangeCredentials Credentials { get; set; }

Property value

Type: Microsoft.Exchange.WebServices.Data.ExchangeCredentials
The credentials that are used to authenticate with EWS.

Setting the Credentials property automatically sets the UseDefaultCredentials property to false.

Caution noteCaution

Be careful not to change the Credentials property after the ExchangeService object has been bound to the Web service. Changing the credentials will cause subsequent Web service operations to fail. To change the Credentials property on the ExchangeService object, you must create a new instance of the ExchangeService object with the credentials that you want.

You cannot use the default credentials of the logged on user if the user’s mailbox is hosted in Exchange Online or Exchange Online as part of Office 365. The user’s credentials must be in user principal name (UPN) form for Exchange Online.