UpdateItemType Class

The UpdateItemType class represents a request to update a set of items.

Namespace: ExchangeWebServices
Assembly: EWS (in ews.dll)


<SerializableAttribute> _
<GeneratedCodeAttribute("wsdl", "2.0.50727.42")> _
<DesignerCategoryAttribute("code")> _
<DebuggerStepThroughAttribute> _
<XmlTypeAttribute(Namespace:="http://schemas.microsoft.com/exchange/services/2006/messages")> _
Public Class UpdateItemType
    Inherits BaseRequestType
[GeneratedCodeAttribute("wsdl", "2.0.50727.42")] 
public class UpdateItemType : BaseRequestType
[GeneratedCodeAttribute(L"wsdl", L"2.0.50727.42")] 
public ref class UpdateItemType : public BaseRequestType
/** @attribute SerializableAttribute() */ 
/** @attribute GeneratedCodeAttribute("wsdl", "2.0.50727.42") */ 
/** @attribute DesignerCategoryAttribute("code") */ 
/** @attribute DebuggerStepThroughAttribute() */ 
/** @attribute XmlTypeAttribute(Namespace="http://schemas.microsoft.com/exchange/services/2006/messages") */ 
public class UpdateItemType extends BaseRequestType
GeneratedCodeAttribute("wsdl", "2.0.50727.42") 
public class UpdateItemType extends BaseRequestType


You can append, set, or delete properties when you update an item.

If you try to submit a change description that includes more than one property to modify, an ErrorIncorrectUpdatePropertyCount error will be returned.

To correctly save the DateTime properties of a task, a time zone is required. However, in versions of Exchange earlier than Exchange Server 2007 Service Pack 2 (SP2), no time zone information is passed to Exchange Web Services (EWS). Starting with Exchange 2007 SP2, EWS includes the ability to specify the time zone when you create task items. For more information, see Updating Exchange Web Services Clients for Exchange 2007 SP2. If you do not specify the time zone when you update tasks in Exchange 2007 SP2, EWS will use the current time zone offset to create the time zone that is used for DateTime properties when the task is updated.

Inheritance Hierarchy



The following code example shows how to update a meeting. This example performs the following actions:

  1. Adds a new required attendee to the meeting.

  2. Updates the start time of the meeting to the current time on the client.

  3. Adds a custom MAPI property to the meeting.

  4. Deletes all optional attendees.

  5. Automatically resolves any conflicts in the update operation.

  6. Sends the meeting update to all attendees and saves a copy of the updated meeting request in the folder that the SavedItemFolderId property identifies.

static void UpdateItem(ExchangeServiceBinding esb)
    // Create calendar items to contain each non-deletion update.
    CalendarItemType ciAppendRA = new CalendarItemType();
    CalendarItemType ciSetStart = new CalendarItemType();
    CalendarItemType ciSetEP = new CalendarItemType();

    // Add a new required attendee to the calendar item.
    ciAppendRA.RequiredAttendees = new AttendeeType[1];
    ciAppendRA.RequiredAttendees[0] = new AttendeeType();
    ciAppendRA.RequiredAttendees[0].Mailbox = new EmailAddressType();
    ciAppendRA.RequiredAttendees[0].Mailbox.EmailAddress = "mskinner@example.com";
    // Identify the field to append.
    PathToUnindexedFieldType appReqAttendees = new PathToUnindexedFieldType();
    appReqAttendees.FieldURI = UnindexedFieldURIType.calendarRequiredAttendees;
    // Add the calendar item and the identified appended field to
    // the ItemChangeDescriptionType. This is an AppendToItemFieldType.
    AppendToItemFieldType append = new AppendToItemFieldType();
    append.Item = appReqAttendees;
    append.Item1 = ciAppendRA;

    // Set a new start time on a calendar item.
    ciSetStart.Start = DateTime.Now;
    ciSetStart.StartSpecified = true;
    // Identify the field to set.
    PathToUnindexedFieldType modStartTime = new PathToUnindexedFieldType();
    modStartTime.FieldURI = UnindexedFieldURIType.calendarStart;
    // Add the calendar item and the identified set field to
    // the ItemChangeDescriptionType. This is a SetItemFieldType.
    SetItemFieldType set = new SetItemFieldType();
    set.Item = modStartTime;
    set.Item1 = ciSetStart;

    // Set a custom property on a calendar item.
    PathToExtendedFieldType setMyProperty = new PathToExtendedFieldType();
    setMyProperty.DistinguishedPropertySetId = DistinguishedPropertySetType.PublicStrings;
    setMyProperty.DistinguishedPropertySetIdSpecified = true;
    setMyProperty.PropertyName = "Milestone date";
    setMyProperty.PropertyType = MapiPropertyTypeType.String;
    // Identify the custom property to set.
    ciSetEP.ExtendedProperty = new ExtendedPropertyType[1];
    ciSetEP.ExtendedProperty[0] = new ExtendedPropertyType();
    ciSetEP.ExtendedProperty[0].ExtendedFieldURI = setMyProperty;
    ciSetEP.ExtendedProperty[0].Item = "2007-07-18";
    // Add the calendar item and the identified custom property
    // to the ItemChangeDescriptionType. This is an SetItemFieldType.
    SetItemFieldType setCustomProp = new SetItemFieldType();
    setCustomProp.Item = setMyProperty;
    setCustomProp.Item1 = ciSetEP;

    // Delete optional attendees from the calendar item.
    PathToUnindexedFieldType delOptAttendees = new PathToUnindexedFieldType();
    delOptAttendees.FieldURI = UnindexedFieldURIType.calendarOptionalAttendees;
    // Add the property to delete to the ItemChangeDescriptionType.
    DeleteItemFieldType deletion = new DeleteItemFieldType();
    deletion.Item = delOptAttendees;            

    // Create the identifier of the item to update.
    ItemIdType itemId = new ItemIdType();
    itemId.Id = "AAAlAE1BQG";
    itemId.ChangeKey = "DwAAABYAAA";

    // Create and populate the request.
    UpdateItemType request = new UpdateItemType();
    request.ItemChanges = new ItemChangeType[1] { new ItemChangeType() };
    request.ItemChanges[0].Item = itemId;
    request.ItemChanges[0].Updates = new ItemChangeDescriptionType[4];
    request.ItemChanges[0].Updates[0] = append;
    request.ItemChanges[0].Updates[1] = set;
    request.ItemChanges[0].Updates[2] = deletion;
    request.ItemChanges[0].Updates[3] = setCustomProp;

    request.ConflictResolution = ConflictResolutionType.AutoResolve;
    request.SendMeetingInvitationsOrCancellations = CalendarItemUpdateOperationType.SendToAllAndSaveCopy;
    request.SendMeetingInvitationsOrCancellationsSpecified = true;

    // Send the update request and receive the response.
    UpdateItemResponseType response = esb.UpdateItem(request);
    ArrayOfResponseMessagesType aormt = response.ResponseMessages;
    ResponseMessageType[] rmta = aormt.Items;

    foreach (ResponseMessageType rmt in rmta)
        ItemInfoResponseMessageType respMsg = (rmt as ItemInfoResponseMessageType);
        foreach (ItemType item in respMsg.Items.Items)
            Console.WriteLine("Item ID: " + item.ItemId.Id);
            Console.WriteLine("New change key: " + item.ItemId.ChangeKey);


The item identifier and change key in the request have been shortened to preserve readability.

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.


Development Platforms

Windows XP Professional with Service Pack 2 (SP2), Windows Server 2003,

Target Platforms

Windows 98, Windows 2000, Windows 2000 Server, Windows CE, Windows Longhorn, Windows 98 Second Edition, Pocket PC, Smart Phone, Windows Server 2003, Windows XP Professional with Service Pack 2 (SP2)