/// <summary> /// Helper method for setting the underlying fields represented by the CompleteName property /// </summary> /// <param name="binding">ExchangeServiceBinding to use for the call</param> /// <param name="contactId">Id and change key of the contact to update</param> /// <param name="completeName">The complete name to set on the contact</param> /// <returns>ItemInfoResponse message due to UpdateItem call</returns> /// public static ItemInfoResponseMessageType SetCompleteName( ExchangeServiceBinding binding, ItemIdType contactId, CompleteNameType completeName) { // Create our request. We will do a single UpdateItem call with a bunch of change descriptions. // UpdateItemType updateRequest = new UpdateItemType(); // We are updating a single item // ItemChangeType itemChange = new ItemChangeType(); itemChange.Item = contactId; updateRequest.ItemChanges = new ItemChangeType[] { itemChange }; // We will only set those props that are not null in the complete name. So right now, we // don't know how many that will be, so let's create a list to hold the change descriptions. // List<ItemChangeDescriptionType> changeList = new List<ItemChangeDescriptionType>(); // Now, for each possible property, let's check to make sure it is not null, then we will set the // value on a ContactItem instance needed for our change description and add it to our change list. // // Title if (completeName.Title != null) { ContactItemType titleContact = new ContactItemType(); ExtendedPropertyType titleProp = new ExtendedPropertyType( TitlePath, completeName.Title); titleContact.ExtendedProperty = new ExtendedPropertyType[] { titleProp }; changeList.Add(new SetItemFieldType(TitlePath, titleContact)); } // GivenName if (completeName.FirstName != null) { ContactItemType givenNameContact = new ContactItemType(); givenNameContact.GivenName = completeName.FirstName; changeList.Add(new SetItemFieldType(GivenNamePath, givenNameContact)); } // MiddleName if (completeName.MiddleName != null) { ContactItemType middleNameContact = new ContactItemType(); middleNameContact.MiddleName = completeName.MiddleName; changeList.Add(new SetItemFieldType(MiddleNamePath, middleNameContact)); } // Surname if (completeName.LastName != null) { ContactItemType surnameContact = new ContactItemType(); surnameContact.Surname = completeName.LastName; changeList.Add(new SetItemFieldType(SurnamePath, surnameContact)); } // Generation if (completeName.Suffix != null) { ContactItemType generationContact = new ContactItemType(); generationContact.Generation = completeName.Suffix; changeList.Add(new SetItemFieldType(GenerationPath, generationContact)); } // Initials if (completeName.Initials != null) { ContactItemType initialsContact = new ContactItemType(); initialsContact.Initials = completeName.Initials; changeList.Add(new SetItemFieldType(InitialsPath, initialsContact)); } // DisplayName if (completeName.FullName != null) { ContactItemType displayNameContact = new ContactItemType(); displayNameContact.DisplayName = completeName.FullName; changeList.Add(new SetItemFieldType(DisplayNamePath, displayNameContact)); } // Nickname if (completeName.Nickname != null) { ContactItemType nicknameContact = new ContactItemType(); nicknameContact.Nickname = completeName.Nickname; changeList.Add(new SetItemFieldType(NicknamePath, nicknameContact)); } // YomiFirstName if (completeName.YomiFirstName != null) { ContactItemType yomiFirstContact = new ContactItemType(); ExtendedPropertyType yomiFirstProp = new ExtendedPropertyType( YomiFirstNamePath, completeName.YomiFirstName); yomiFirstContact.ExtendedProperty = new ExtendedPropertyType[] { yomiFirstProp }; changeList.Add(new SetItemFieldType(YomiFirstNamePath, yomiFirstContact)); } // YomiLastName if (completeName.YomiLastName != null) { ContactItemType yomiLastContact = new ContactItemType(); ExtendedPropertyType yomiLastProp = new ExtendedPropertyType( YomiLastNamePath, completeName.YomiLastName); yomiLastContact.ExtendedProperty = new ExtendedPropertyType[] { yomiLastProp }; changeList.Add(new SetItemFieldType(YomiLastNamePath, yomiLastContact)); } // If they passed in a CompleteName with all NULL props, we should fail. // if (changeList.Count == 0) { throw new ArgumentException("No parts of CompleteName were set", "completeName"); } itemChange.Updates = changeList.ToArray(); updateRequest.ConflictResolution = ConflictResolutionType.AlwaysOverwrite; // Make the call and return the response message // return binding.UpdateItem(updateRequest).ResponseMessages.Items[0] as ItemInfoResponseMessageType; }
/// <remarks/> public void UpdateItemAsync(UpdateItemType UpdateItem1) { this.UpdateItemAsync(UpdateItem1, null); }
/// <remarks/> public void UpdateItemAsync(UpdateItemType UpdateItem1, object userState) { if ((this.UpdateItemOperationCompleted == null)) { this.UpdateItemOperationCompleted = new System.Threading.SendOrPostCallback(this.OnUpdateItemOperationCompleted); } this.InvokeAsync("UpdateItem", new object[] { UpdateItem1}, this.UpdateItemOperationCompleted, userState); }
/// <remarks/> public System.IAsyncResult BeginUpdateItem(UpdateItemType UpdateItem1, System.AsyncCallback callback, object asyncState) { return this.BeginInvoke("UpdateItem", new object[] { UpdateItem1}, callback, asyncState); }