EWS Managed API code samples

Find code samples that show you how to perform specific tasks by using the EWS Managed API.

Last modified: July 01, 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.

This article provides information about the code samples that are available for the EWS Managed API. These code samples are part of the Exchange 2013: 101 code samples project, and each sample demonstrates how to use the EWS Managed API to perform a specific task, such as getting the Out of Office (OOF) status of a user or sending an email message. The samples are compilable and are typically in the form of Visual Studio 2010 solutions.

Use the samples listed in the following table to learn how to get availability information from the Exchange server so that your application can suggest meeting times.

Sample

Description

Exchange 2013: Get users' status setting programmatically

Authenticates an email address and password entered from the console, gets the free/busy status for a meeting organizer and a prospective meeting attendee, and then writes their availability status to the console.

Exchange 2013: Retrieve a set of meeting times for prospective attendees

Authenticates an email address and password entered from the console, specifies a set of meeting time options, such as duration, suggestion quality threshold, and time window, and then retrieves a set of suggested meeting times from an Exchange server and displays them to the console.

Exchange 2013: Get a conference room from a room list programmatically

Authenticates an email address and password entered from the console, retrieves a room list that matches a specific email address, and then displays the rooms in the room list to the console.

The samples listed in the following table show you how to work with the contact lists associated with an email account.

Sample

Description

Exchange 2013: Find contacts by their display names programmatically

Authenticates an email address and password entered from the console, searches the contacts folder for a contact that matches a supplied display name, and then either returns a contact object that matches the display name if a unique instance is found, or returns null if no matching contact is found or if there are multiple contacts with the same display name.

Exchange 2013: Update contacts programmatically on Exchange servers

Authenticates an email address and password entered from the console, looks for a contact by display name, creates the contact if the contact is not found, updates a property on the contact (the company name), and then commits the change to the Exchange server.

Exchange 2013: Delete contacts programmatically from Exchange servers

Authenticates an email address and password entered from the console, looks for a contact by display name, creates the contact if not found, and then deletes the contact.

Exchange 2013: Retrieve contact items from the Contacts folder programmatically

Authenticates an email address and password entered from the console and displays the display name of all of the contact items in the Contacts folder to the console.

Exchange 2013: Delete contact property groups by using extended properties

Authenticates an email address and password entered from the console, looks for a supplied contact, creates the contact if the contact is not found, deletes an email address group for the contact, and then commits the change to the Exchange server.

Exchange 2013: Create contacts programmatically on Exchange servers

Authenticates an email address and password entered from the console, creates a contact, populates the contact object with contact information, and saves the contact to the Exchange server.

The samples listed in the following table show you how to get and display the email addresses that are members of distribution or room lists.

Sample

Description

Exchange 2013: Expand distribution lists programmatically on Exchange servers

Authenticates an email address and password entered from the console, retrieves a set of email addresses that are associated with a distribution list, and displays the email addresses to the console.

Exchange 2013: Get a room list programmatically by using the EWS Managed API

Authenticates an email address and password entered from the console, retrieves all the room lists in the organization that are associated with the authenticated email address, and then displays all the room lists to the console.

Use the samples listed in the following table to learn how to create, retrieve and send email messages.

Sample

Description

Exchange 2013: Send delayed emails programmatically on Exchange servers

Authenticates an email address and password entered from the console, creates an email message, sets properties on the message, and submits the request to send the message. An extended property set on the email message specifies the time in the future when the email will be sent.

Exchange 2013: Update email on Exchange servers programmatically

Authenticates an email address and password entered from the console, creates an email message, and saves the email message in the authenticated user's Drafts folder. It then updates the importance of the message and the body of the message, and saves the updates to the server.

Exchange 2013: Create draft emails programmatically on Exchange servers

Authenticates an email address and password entered from the console, creates an email message, and saves the email message in the authenticated user's Drafts folder (where it can be retrieved, updated, and sent at a later time).

Exchange 2013: Delete emails programmatically from Exchange servers

Authenticates an email address and password entered from the console, finds three items in the authenticated user's Inbox folder that contain the word "advertisement" in the subject, and deletes each of the three items by using a distinct mode of deletion. For the sample to work as designed, exactly three items in the Inbox folder must contain the word "advertisement".

Exchange 2013: Attach files to email messages programmatically

Authenticates an email address and password entered from the console and creates a new email message. It then creates a second email message, which is attached to the first message, and sends the new email message to the email address of the authenticated user.

The samples listed in the following table show you how to use folders on the Exchange server. You can use these samples to learn how create, delete, copy and empty folders.

Sample

Description

Exchange 2013: Find folder identifiers by using their display names programmatically

Authenticates an email address and password entered from the console and retrieves the unique identifier of a folder by using the folder's display name. Getting a folder's unique identifier in this way is useful because the identifier is required to update or delete an existing folder.

Exchange 2013: Update folder display names programmatically on Exchange servers

Authenticates an email address and password entered from the console and updates the display name of a folder in the authenticated user’s Inbox folder on the Exchange server. The sample retrieves the unique identifier of the folder to be updated by using the folder’s display name, binds to the folder by using its identifier, updates the folder's display name, and saves the change to the folder.

Exchange 2013: Move folders programmatically on Exchange servers

Authenticates an email address and password entered from the console and moves a folder from the authenticated user's Inbox folder to the authenticated user's Drafts folder on the Exchange server. The sample retrieves the unique identifier of the folder to be moved by using the folder's display name, binds to the folder by using its identifier, and moves the folder.

Exchange 2013: Copy folders programmatically on Exchange servers

Authenticates an email address and password entered from the console and copies a folder from the authenticated user's Inbox folder to the authenticated user's Drafts folder on the Exchange server. The sample retrieves the unique identifier of the folder to be copied by using the folder's display name, binds to the folder by using its identifier, and copies the folder.

Exchange 2013: Create folders programmatically on Exchange servers

Authenticates an email address and password entered from the console, and creates a new folder in the authenticated user’s Inbox folder on the Exchange server.

Exchange 2013: Delete folders programmatically from Exchange servers

Authenticates an email address and password entered from the console and permanently deletes a folder from the authenticated user's Inbox folder on the Exchange server. The sample retrieves the unique identifier of the folder to be deleted by using the folder's display name, binds to the folder by using its identifier, and deletes the folder.

Exchange 2013: Empty folders on Exchange servers programmatically

Authenticates an email address and password entered from the console and permanently deletes the contents of a folder that is located in the authenticated user's Inbox folder on the Exchange server. The sample retrieves the unique identifier of the folder to be emptied by using the folder's display name, binds to the folder by using its identifier, and empties the folder.

The sample listed in the following table shows you how to get user names associated with an email address.

Sample

Description

Exchange 2013: Get user names for an account by using the Name Resolver service

Authenticates an email address and password entered from the console and searches the authenticated user's Contacts folder, and AD DS, for any accounts that match the name provided.

The samples listed in the following table show you how to monitor an email account's Inbox and respond when new items are received.

Sample

Description

Exchange 2013: Set pull notifications for applications programmatically

Authenticates an email address and password entered from the console, creates a pull subscription in the authenticated user's Inbox folder on the Exchange server, and monitors the Inbox for new mail, items created, and items deleted.

Exchange 2013: Set streaming notifications for applications programmatically

Authenticates an email address and password entered from the console, creates a streaming subscription in the authenticated user's Inbox folder on the Exchange server, and monitors the Inbox for new mail, items created, and items deleted.

You can use the samples listed in the following table to learn how to get and set the Out of Office (OOF) response message that is automatically sent when an account receives an email.

Sample

Description

Exchange 2013: Set users' Out of Office settings programmatically

Authenticates an email address and password entered from the console, sets the user's OOF settings, and then retrieves the user's OOF message.

Exchange 2013: Get users' Out of Office settings programmatically

Authenticates an email address and password entered from the console, and retrieves a user's automatic replies.

The samples listed in the following table show you how to use the EWS Managed API to create, modify, and delete tasks. You can use the samples to learn how to work with both one-time and recurring tasks.

Sample

Description

Exchange 2013: Create recurring tasks programmatically on Exchange servers

Authenticates an email address and password entered from the console, creates a task in the authenticated user's task folder, and sets a recurrence pattern.

Exchange 2013: Create tasks programmatically on Exchange servers

Authenticates an email address and password entered from the console and creates a task in the authenticated user's task folder.

Exchange 2013: Modify existing tasks programmatically on Exchange servers

Authenticates an email address and password entered from the console and updates the status of a task on the Exchange server. It retrieves the task to be updated by using the task's subject, binds to the task by using its identifier, updates the status of the task, and saves the change to the task.

Exchange 2013: Delete tasks from an account on Exchange servers programmatically

Authenticates an email address and password entered from the console and deletes a task from the authenticated user's Tasks folder. The sample retrieves the task to be updated by using the task's subject, binds to the task by using its identifier, and deletes the task.

Exchange 2013: Find tasks by their subjects programmatically on Exchange servers

Authenticates an email address and password entered from the console and retrieves the task item by using the task's subject. Getting a task item in this way is useful because the task identifier is required to update or delete an existing task item.

The samples listed in the following table show you how to use the EWS Managed API to retrieve and modify user information and configuration details.

Sample

Description

Exchange 2013: Create user configuration objects programmatically

Authenticates an email address and password entered from the console and creates a user configuration object to store XML and binary data.

Exchange 2013: Delete user configuration objects programmatically

Authenticates an email address and password entered from the console and deletes a user configuration object.

Exchange 2013: Get user configuration objects programmatically

Authenticates an email address and password entered from the console and gets a user configuration object to display its XML and binary data.

Exchange 2013: Modify user configuration objects programmatically

Authenticates an email address and password entered from the console and modifies a user configuration object to store dictionary property values.

Exchange 2013: Find associated user information programmatically

Authenticates an email address and password entered from the console, finds the associated items in the authenticated user's Inbox, and outputs a list of the item classes.

Show:
© 2014 Microsoft