Getting Started with Exchange Web Services Managed API 1.1

Document Sample
Getting Started with Exchange Web Services Managed API 1.1 Powered By Docstoc
					Hands-On Lab
Getting Started with the EWS Managed API
1.1 - Working with Extended Properties
Lab version:    1.0
Last updated:   6/19/2012
CONTENTS

OVERVIEW ................................................................................................................................................... 3
 System Requirements                                                                                                                                         3

EXERCISE 1: WORKING WITH EXTENDED PROPERTIES...................................................................... 3
       Task 1 – Beginning the Exercise ............................................................................................................ 3
       Task 2 – Create Items and Extended Properties ................................................................................... 4
       Task 3 – Finding Items with Extended Properties ................................................................................. 4

SUMMARY .................................................................................................................................................... 5
Overview
Lab Time: 45 minutes
Lab Folder: C:\%Office365TrainingKit%\Labs\10.2\Source\Before

 The After folder contains the completed lab exercises.

Lab Overview: The Microsoft Exchange Web Services (EWS) Managed API 1.1 provides an intuitive
managed API for developing client and server applications that leverage data and business logic from
Exchange, whether Exchange is running on premises or in the cloud. The EWS Managed API 1.1 makes
Exchange Web Services SOAP calls “under the covers” so many environments are already configured for
EWS Managed API 1.1.
In this lab, you will use the EWS Managed API 1.1 to:
       Apply extended properties to mailbox items.
       Perform complex searches for mailbox items with a specific extended property.


System Requirements
You must have the following items to complete this lab:

       Microsoft Visual Studio 2010

       Exchange Web Services Managed API 1.1 SDK
       Two accounts configured to have Microsoft Exchange mailboxes, referred to as the primary and
        secondary lab users in this lab.



Exercise 1: Working with Extended
Properties
Task 1 – Beginning the Exercise
In this task, you will open the project and configure it to run with your accounts.
        1. Navigate to Start >> All Programs >> Microsoft Visual Studio 2010.
        2. Click on the Microsoft Visual Studio 2010 icon to start Visual Studio 2010.
        3. Select File >> Open Project.
        4. Navigate to the folder C:\%Office365TrainingKit%\Labs\10.2\Source\Before\
           EWSMA_ExtendedProperties.sln.
       5. Open the EWSMA_ExtendedProperties project.
       6. In Solution Explorer, open the app.config file.
       7. Change the PrimaryLabUserId and SecondaryLabUserId values to your primary and
          secondary lab accounts.
Task 2 – Create Items and Extended Properties
In this task, you will create an extended property, attach it to an appointment, and set its value.
       1. Navigate to TODO: 10.2.1.
       2. Add the following code after the TODO: 10.2.1 comment. This defines a “Customer ID”
          property for an appointment and assigns the property the value “12345”.
                C#
                ExtendedPropertyDefinition extendedProperty = new
                ExtendedPropertyDefinition(
                       DefaultExtendedPropertySet.Appointment,
                       _extendedPropertyName,
                       MapiPropertyType.String);

                appointment.SetExtendedProperty(extendedProperty, _customerId);

                appointment.Save(SendInvitationsMode.SendToAllAndSaveCopy);

Task 3 – Finding Items with Extended Properties
In this task, you will use the Extended Property defined above to find the Appointment you created.
       1. Navigate to TODO: 10.2.2.
       2. Un-comment code surrounded by /* … */ block to display the search results.
       3. Add the following code after the TODO: 10.2.2 comment. This finds all appointments in your
          Calendar with the “Customer ID” extended property.
                C#
                ItemView itemView = new ItemView(10);

                ExtendedPropertyDefinition extendedProperty =
                    new ExtendedPropertyDefinition(
                        DefaultExtendedPropertySet.Appointment,
                        _extendedPropertyName,
                        MapiPropertyType.String);

                itemView.PropertySet = new PropertySet(
                       BasePropertySet.IdOnly,
                       ItemSchema.Subject,
                       AppointmentSchema.Start,
                       AppointmentSchema.End,
                       extendedProperty);
               SearchFilter filter = new SearchFilter.Exists(extendedProperty);

               FindItemsResults<Item> appointments =_service.FindItems(
                      WellKnownFolderName.Calendar,
                      filter,
                      itemView);



       4. Go to Debug >> Start Without Debugging or press [CTRL]+[F5] to start the application.
       5. Press “1” to create an appointment with the “Customer ID” extended property.
       6. Open Outlook 2010 and verify that the appointment is in the Calendar. The extended
          property is not visible in Outlook.
       7. Press “2” to view appointments with the “Customer ID” extended property.
       8. Verify that the appointment created previously displays with the “Customer ID” value of
          “12345”.




Summary
In this lab, you used the EWS Managed API to build simple applications that leverage Exchange 2010
data and business logic. You learned how to attach metadata to mailbox items using Extended
Properties and how to search for mailbox items with a given Extended Property.

				
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
views:58
posted:6/19/2012
language:German
pages:5