Partager via


Updating a recurring series by using the EWS Managed API 2.0

Last modified: October 13, 2012

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.

You can use the Microsoft Exchange Web Services (EWS) Managed API to update a recurring series of calendar items. This topic contains information about how to update a recurring series of appointments or meetings. For information about how to update a single appointment or meeting in a recurring series, see Modifying and deleting items in a recurring series by using the EWS Managed API 2.0.

To update a recurring series of appointments or meetings

  1. Bind to the recurring master item for the series that you want to update by using its unique identifier. For information about how to get the unique identifier of the recurring master item in a recurring series, see Accessing calendar items in a recurring series by using the EWS Managed API 2.0. The following code shows how to bind to an existing recurring master item and provide it with connection configuration information by using an ExchangeService object named service. The ItemId has been shortened to preserve readability.

    Appointment appointment = Appointment.Bind(service, new ItemId("AAMkA="));
    
  2. Update properties on the recurring master item. The following code shows how to update the subject, the start time, and the end time on a recurring master item for a series of appointments or meetings.

    appointment.Subject = "Urgent Status Update";
    appointment.Start = new DateTime(2009, 3, 5, 9, 0, 0);
    appointment.End = appointment.Start.AddHours(1);
    
  3. Save the changes to the recurring master item. The following code shows how to save an updated recurring master item for a recurring series of appointments or meetings. Before performing the update, the code verifies that the appointment is a recurring master item. For a list of the methods that you can use to save or to save and send updated appointments or meeting requests, see Updating appointments and meetings by using the EWS Managed API 2.0.

    if (appointment.AppointmentType == AppointmentType.RecurringMaster)
    {
       appointment.Update(ConflictResolutionMode.AlwaysOverwrite);
    }
    

Example

Updating a recurring series of meetings

The following code example shows how to update the subject, the location, the start time, the end time, and the recurrence information for a recurring series of meetings. The updated meeting series request is sent to all attendees and a copy is saved in the organizer's Sent Items folder. This example assumes that service is a valid ExchangeService binding. The ItemId has been shortened to preserve readability.

// Bind to the recurring master item for the series by using its unique identifier.
Appointment appointment = Appointment.Bind(service, new ItemId("AAMkA="));

// Update subject, location, start time, and end time of the recurring meeting.
appointment.Subject = "Status Meeting – New Time & Location";
appointment.Location = "Conf Room 34";
appointment.Start = new DateTime(2009, 3, 5, 10, 0, 0);
appointment.End = appointment.Start.AddHours(1);

// Update recurrence informaton.
// The meeting will recur daily for four days, starting on March 5, 2009.
appointment.Recurrence = new Recurrence.DailyPattern(appointment.Start.Date, 1);
appointment.Recurrence.StartDate = appointment.Start.Date;
appointment.Recurrence.EndDate = (appointment.Start.Date).AddDays(3);

// If the appointment is a recurring master item, save the updated recurring master item and send the updated meeting series request to all attendees. 
if (appointment.AppointmentType == AppointmentType.RecurringMaster)
{
   appointment.Update(ConflictResolutionMode.AlwaysOverwrite, SendInvitationsOrCancellationsMode.SendToAllAndSaveCopy);
}

Compiling the code

For information about compiling this code, see Getting started with the EWS Managed API 2.0.

Robust programming

  • Write appropriate error handling code for common search errors.

  • Review the client request XML that is sent to the Exchange server.

  • Review the server response XML that is sent from the Exchange server.

  • Set the service binding as shown in Setting the Exchange service URL by using the EWS Managed API 2.0. Do not hard code URLs because if mailboxes move, they might be serviced by a different Client Access server. If the client cannot connect to the service, retry setting the binding by using the AutodiscoverUrl(String) method.

  • Set the target Exchange Web Services schema version by setting the requestedServerVersion parameter of the ExchangeService constructor. For more information, see Versioning EWS requests by using the EWS Managed API 2.0.

Security

  • Use HTTP with SSL for all communication between client and server.

  • Always validate the server certificate that is used for establishing the SSL connections. For more information, see Validating X509 certificates by using the EWS Managed API 2.0.

  • Do not include user names and passwords in trace files.

  • Verify that Autodiscover lookups that use HTTP GET to find an endpoint always prompt for user confirmation; otherwise, they should be blocked.