Export (0) Print
Expand All

ExchangeService object

Learn how to manage connections to an Exchange server.

Last modified: January 25, 2013

Applies to: EWS Managed API | Exchange Server 2007 Service Pack 1 (SP1) | Exchange Server 2010

Note: This content applies to the EWS Managed API 2.0 and earlier versions. For the latest information about the EWS Managed API, see Web services in Exchange.

In this article
Managing endpoints
Authentication
Working with groups of items
Working with delegates

The ExchangeService object manages the connection between Exchange Web Services (EWS) and your Microsoft Exchange Web Services Managed API application. It provides properties and methods that authenticate your application account holders to EWS, methods that enable you to work with batches of Exchange items at the same time, and methods that enable you to work with account delegates. Exchange item objects, such as the Appointment object, the EmailMessage object, and the Task object, use the ExchangeService object to provide the connection to the Exchange server.

This topic provides a general introduction to the ExchangeService object and does not cover the specifics of using EWS Managed API objects. For specific information about using EWS Managed API objects, see the topics listed in the See Also section later in this topic.

The ExchangeService object provides two methods for specifying the URL endpoint of the EWS server that your application communicates with. In most cases, you can use the AutodiscoverUrl method to automatically find the correct endpoint for a particular account. If you have the endpoint URL cached, you can set the Url property to specify the correct endpoint.

For more information about using the AutodiscoverUrl method, see Setting the Exchange service URL by using the EWS Managed API.

You can use one of three methods to authenticate your application with the EWS server and perform actions on behalf of account holders.

You can set the UseDefaultCredentials property of the ExchangeService object to true to use the default Windows credentials of the application user. When you use the default credentials, your application can connect to the EWS server without asking the user for a username and password combination; however, the server and the client computer must use a common set of users.

You can use the Credentials property of the ExchangeService object to set the username and password of the account to use on the EWS server. The Credentials property uses a System.Net.Credentials object to securely store the user’s authentication information.

You can set the Credentials property of the ExchangeService object to the username and password of a service account on the EWS server and then set the ImpersonatedUserId property to the SMTP address of the user account to manage. When you use the ImpersonatedUserId property, the service account must be given impersonation rights on the user account. For more information about impersonation, see Working with impersonation by using the EWS Managed API.

Note Note

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 updated credentials.

All Exchange item objects, such as Appointment objects, EmailMessage objects, and Task objects, are descended from the base Item class. You can use the Item object base methods (CreateItems, FindItems, and so on) on the ExchangeService object to work with groups of items, such as moving all e-mail messages to a new folder, or marking a group of tasks as complete.

For more information about Exchange items, see Item types in the EWS Managed API.

Your account holders can grant other account holders delegate rights on their account, giving the delegate permission to act on the primary account holder’s behalf. You can use the delegation methods, AddDelegates, GetDelegates, UpdateDelegates, and RemoveDelegates, to manage the delegate users for account holders.

For more information about delegates, see Working with delegate access by using the EWS Managed API.

Show:
© 2014 Microsoft