UpdateItemType Class

Definition

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

public ref class UpdateItemType : ExchangeWebServices::BaseRequestType
public class UpdateItemType : ExchangeWebServices.BaseRequestType
Public Class UpdateItemType
Inherits BaseRequestType
Inheritance
UpdateItemType

Examples

The following code example shows you 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 <span class="label">request</span> = new <span class="label">UpdateItemType</span>();
<span class="label">request</span>.ItemChanges = new ItemChangeType[1] { new ItemChangeType() };
<span class="label">request</span>.ItemChanges[0].Item = itemId;
<span class="label">request</span>.ItemChanges[0].Updates = new ItemChangeDescriptionType[4];
<span class="label">request</span>.ItemChanges[0].Updates[0] = append;
<span class="label">request</span>.ItemChanges[0].Updates[1] = set;
<span class="label">request</span>.ItemChanges[0].Updates[2] = deletion;
<span class="label">request</span>.ItemChanges[0].Updates[3] = setCustomProp;

<span class="label">request</span>.ConflictResolution = ConflictResolutionType.AutoResolve;
<span class="label">request</span>.SendMeetingInvitationsOrCancellations = CalendarItemUpdateOperationType.SendToAllAndSaveCopy;
<span class="label">request</span>.SendMeetingInvitationsOrCancellationsSpecified = true;

    // Send the update request and receive the response.
    UpdateItemResponseType response = esb.UpdateItem(<span class="label">request</span>);
    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);
            Console.ReadLine();
        }
    }
}

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

Remarks

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.

Constructors

UpdateItemType()

The UpdateItemType constructor initializes a new instance of the UpdateItemType class.

Properties

ConflictResolution

The ConflictResolution property gets or sets an enumeration value that represents the type of conflict resolution that is performed during an update. This property is required. This is a read/write property.

ItemChanges

The ItemChanges property gets or sets an array of item changes. This property is required. This is a read/write property.

MessageDisposition

The MessageDisposition property gets or sets an enumeration value that describes how a message item is handled after it is updated. This property is required for message items, including meeting messages such as meeting cancellations, meeting requests, and meeting responses. This is a read/write property.

MessageDispositionSpecified

The MessageDispositionSpecified property gets or sets a Boolean value that specifies whether the MessageDisposition property is serialized into the Simple Object Access Protocol (SOAP) request. This property is required if the MessageDisposition property is set. This is a read/write property.

SavedItemFolderId

The SavedItemFolderId property gets or sets the target folder for saved items. This property is set with either a FolderIdType or DistinguishedFolderIdType object. This property is optional. This is a read/write property.

SendMeetingInvitationsOrCancellations

The SendMeetingInvitationsOrCancellations property gets or sets an enumeration value that describes how a calendar item is handled after it is updated. This property is required for calendar items. This is a read/write property.

SendMeetingInvitationsOrCancellationsSpecified

The SendMeetingInvitationsOrCancellationsSpecified property gets or sets a Boolean value that specifies whether the SendMeetingInvitationsOrCancellations property is serialized into the Simple Object Access Protocol (SOAP) request. This property is required if the SendMeetingInvitationsOrCancellations property is set. This is a read/write property.

Applies to