UpdateItemType 类

定义

UpdateItemType 表示更新一组项的请求。

public ref class UpdateItemType : ExchangeWebServices::BaseRequestType
public class UpdateItemType : ExchangeWebServices.BaseRequestType
Public Class UpdateItemType
Inherits BaseRequestType
继承
UpdateItemType

示例

下面的代码示例演示如何更新会议。 本示例执行以下操作:

  1. 将新的所需与会者添加到会议。
  2. 汇报客户端上的会议开始时间到当前时间。
  3. 向会议添加自定义 MAPI 属性。
  4. 删除所有可选与会者。
  5. 自动解决更新作中的任何冲突。
  6. 将会议更新发送给所有与会者,并将更新的会议请求的副本保存在 属性标识的 文件夹中 SavedItemFolderId
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();
        }
    }
}

注意:请求中的项标识符和更改键已缩短,以保持可读性。

注解

更新项时,可以追加、设置或删除属性。

如果尝试提交包含多个要修改的属性的更改说明,将返回错误 ErrorIncorrectUpdatePropertyCount

构造函数

UpdateItemType()

构造 UpdateItemType 函数初始化 类的新实例 UpdateItemType

属性

ConflictResolution

属性 ConflictResolution 获取或设置一个枚举值,该值表示更新期间执行的冲突解决类型。 此属性是必需项。 这是一个读/写属性。

ItemChanges

属性 ItemChanges 获取或设置项更改的数组。 此属性是必需项。 这是一个读/写属性。

MessageDisposition

属性 MessageDisposition 获取或设置一个枚举值,该值描述更新消息项后如何处理它。 此属性对于消息项是必需的,包括会议消息,例如会议取消、会议请求和会议响应。 这是一个读/写属性。

MessageDispositionSpecified

属性 MessageDispositionSpecified 获取或设置一个布尔值,该值指定属性是否 MessageDisposition 序列化为简单对象访问协议 (SOAP) 请求。 如果设置了属性, MessageDisposition 则需要此属性。 这是一个读/写属性。

SavedItemFolderId

属性 SavedItemFolderId 获取或设置已保存项目的目标文件夹。 此属性是使用 或 DistinguishedFolderIdType 对象设置的FolderIdType。 此属性可选。 这是一个读/写属性。

SendMeetingInvitationsOrCancellations

属性 SendMeetingInvitationsOrCancellations 获取或设置一个枚举值,该值描述更新日历项后如何处理它。 此属性对于日历项是必需的。 这是一个读/写属性。

SendMeetingInvitationsOrCancellationsSpecified

属性 SendMeetingInvitationsOrCancellationsSpecified 获取或设置一个布尔值,该值指定属性是否 SendMeetingInvitationsOrCancellations 序列化为简单对象访问协议 (SOAP) 请求。 如果设置了属性, SendMeetingInvitationsOrCancellations 则需要此属性。 这是一个读/写属性。

适用于