/// <summary> /// Clean up the items which contain a specified subject in the specified folder. /// </summary> /// <param name="folder">The folder to be cleaned up.</param> /// <param name="subject">Subject of the item to be removed.</param> /// <returns>If succeed, return true; otherwise, return false.</returns> private bool CleanupFolder(string folder, string subject) { ItemIdType[] items = this.GetItemIds(folder, subject); if (items != null && items.Length > 0) { DeleteItemType deleteItem = new DeleteItemType(); deleteItem.ItemIds = items; deleteItem.DeleteType = DisposalType.HardDelete; deleteItem.SendMeetingCancellations = CalendarItemCreateOrDeleteOperationType.SendToNone; deleteItem.SendMeetingCancellationsSpecified = true; DeleteItemResponseType response = this.exchangeServiceBinding.DeleteItem(deleteItem); if (response.ResponseMessages.Items != null) { foreach (ResponseMessageType item in response.ResponseMessages.Items) { if (item.ResponseClass != ResponseClassType.Success) { return(false); } } } } return(true); }
/// <summary> /// Log on to a mailbox with a specified user account and find the specified item then delete it. /// </summary> /// <param name="userName">Name of the user.</param> /// <param name="userPassword">Password of the user.</param> /// <param name="userDomain">Domain of the user.</param> /// <param name="folderName">Name of the folder which should be searched for the specified item.</param> /// <param name="itemSubject">Subject of the item which should be deleted.</param> /// <param name="itemType">Type of the item which should be deleted.</param> /// <returns>If the specified item is deleted successfully, return true; otherwise, return false.</returns> public bool FindAndDeleteItem(string userName, string userPassword, string userDomain, string folderName, string itemSubject, string itemType) { // Switch to specified user mailbox. bool isSwitched = AdapterHelper.SwitchUser(userName, userPassword, userDomain, this.exchangeServiceBinding, this.Site); Site.Assert.IsTrue( isSwitched, string.Format("Log on mailbox with the UserName: {0}, Password: {1}, Domain: {2} should be successful.", userName, userPassword, userDomain)); // Parse the parent folder name to DistinguishedFolderIdNameType. DistinguishedFolderIdNameType parentFolderIdName = (DistinguishedFolderIdNameType)Enum.Parse(typeof(DistinguishedFolderIdNameType), folderName, true); Item item = (Item)Enum.Parse(typeof(Item), itemType, true); ItemType type = this.LoopToFindItem(parentFolderIdName, itemSubject, item); bool isDeleted = false; if (type != null) { DeleteItemType deleteItemRequest = new DeleteItemType(); deleteItemRequest.ItemIds = new BaseItemIdType[] { type.ItemId }; // Invoke the delete item operation and get the response. DeleteItemResponseType response = this.exchangeServiceBinding.DeleteItem(deleteItemRequest); if (response != null && response.ResponseMessages.Items[0].ResponseClass == ResponseClassType.Success) { // If delete operation succeeds, return true isDeleted = true; } } return(isDeleted); }
/// <summary> /// Delete tasks on the server according to items' id. /// </summary> /// <param name="itemIds">The item id of tasks which will be deleted.</param> protected void DeleteTasks(params ItemIdType[] itemIds) { // Define the DeleteItem request. DeleteItemType deleteItemRequest = TestSuiteHelper.GenerateDeleteItemRequest(itemIds); // Call the DeleteItem method to delete the task items created in previous steps. DeleteItemResponseType deleteItemResponse = this.TASKAdapter.DeleteItem(deleteItemRequest); this.VerifyResponseMessage(deleteItemResponse); }
/// <summary> /// Validates the StatusType object. /// </summary> /// <param name="_status">The statuses to validate.</param> /// <param name="_str">Used to return detailed comments of failures.</param> /// <param name="_error">Indicates the succes of the validation. True is a failure and _str should be consulted for details.</param> /// <param name="_items">The data items that were used in the request. These are used for better error reporting.</param> /// <remarks>Anything other than StatusTypeCode.OK is appened to the _str parameter.</remarks> private void ValidateStatus(StatusType[] _status, StringBuilder _str, ref bool _error, DataItemBaseType[] _items) { if (_status != null) { foreach (StatusType status in _status) { if (status.code != StatusTypeCode.OK) { _error = true; DataItemBaseType item = _items.Where(it => it.itemID == status.@ref).FirstOrDefault(); string id = null; if (item is CreateItemType) { CreateItemType cItem = item as CreateItemType; if (cItem.NewData.Count() > 0) { id = String.Format(" [{0} : {1}]", cItem.NewData[0].GetType().Name, cItem.NewData[0].iid); } } else if (item is ModifyItemType) { ModifyItemType mItem = item as ModifyItemType; if (mItem.NewData.Count() > 0) { id = String.Format(" [{0} : {1}]", mItem.NewData[0].GetType().Name, mItem.NewData[0].iid); } } else if (item is DeleteItemType) { DeleteItemType dItem = item as DeleteItemType; if (dItem.Select != null && dItem.Select.Item is QrySimpleTextType) { id = String.Format(" [{0} : {1}]", dItem.objectType.ToString(), (dItem.Select.Item as QrySimpleTextType).Query); } } else if (item is QueryItemType) { QueryItemType qItem = item as QueryItemType; if (qItem.Select != null && qItem.Select.Item is QrySimpleTextType) { id = String.Format(" [{0} : {1}]", qItem.objectType.ToString(), (qItem.Select.Item as QrySimpleTextType).Query); } } _str.Append(String.Format("## {0}{1} - {2}", status.code.ToString(), id == null ? "" : id, status.comment)); ValidateStatus(status.Status, _str, ref _error, _items); } } } }
/// <summary> /// Delete items on the server. /// </summary> /// <param name="deleteItemRequest">Specify a request to delete item on the server.</param> /// <returns>A response to this operation request.</returns> public DeleteItemResponseType DeleteItem(DeleteItemType deleteItemRequest) { if (deleteItemRequest == null) { throw new ArgumentException("The DeleteItem request should not be null."); } DeleteItemResponseType response = this.exchangeServiceBinding.DeleteItem(deleteItemRequest); return(response); }
/// <summary> /// Delete contact item on the server. /// </summary> /// <param name="deleteItemRequest">The request of DeleteItem operation.</param> /// <returns>A response to DeleteItem operation request.</returns> public DeleteItemResponseType DeleteItem(DeleteItemType deleteItemRequest) { DeleteItemResponseType deleteItemResponse = this.exchangeServiceBinding.DeleteItem(deleteItemRequest); #region Verify DeleteItem operation requirements this.VerifySoapVersion(); this.VerifyTransportType(); this.VerifyDeleteContactItem(this.exchangeServiceBinding.IsSchemaValidated); #endregion return(deleteItemResponse); }
/// <summary> /// Delete the calendar related item elements. /// </summary> /// <param name="request">A request to the DeleteItem operation.</param> /// <returns>The response message returned by DeleteItem operation.</returns> public DeleteItemResponseType DeleteItem(DeleteItemType request) { if (request == null) { throw new ArgumentException("The request of operation 'DeleteItem' should not be null."); } DeleteItemResponseType deleteItemResponse = this.exchangeServiceBinding.DeleteItem(request); this.VerifySoapVersion(); this.VerifyTransportType(); this.VerifyDeleteItemOperation(this.exchangeServiceBinding.IsSchemaValidated); return(deleteItemResponse); }
private static DeleteItemType getDeleteItem(LinkIDAttribute attribute) { DeleteItemType deleteItem = new DeleteItemType(); deleteItem.objectType = DataServiceConstants.ATTRIBUTE_OBJECT_TYPE; SelectType select = new SelectType(); select.Value = attribute.attributeName; if (null != attribute.attributeId) { setAttributeId(select, attribute.attributeId); } return(deleteItem); }
/// <summary> /// Deletes Task items on the server. /// </summary> /// <param name="deleteItemRequest">Specifies a request to delete Task item on the server.</param> /// <returns>A response to this operation request.</returns> public DeleteItemResponseType DeleteItem(DeleteItemType deleteItemRequest) { DeleteItemResponseType deleteItemResponse = this.exchangeServiceBinding.DeleteItem(deleteItemRequest); // Verify the delete item operation. this.VerifyDeleteItemOperation(this.exchangeServiceBinding.IsSchemaValidated); // Verify Soap version requirements. this.VerifySoapVersion(); // Verify transport requirements. this.VerifyTransportType(); return(deleteItemResponse); }
/// <summary> /// Delete items on the server. /// </summary> /// <param name="deleteItemRequest">Specify a request to delete item on the server.</param> /// <returns>A response to DeleteItem operation request.</returns> public DeleteItemResponseType DeleteItem(DeleteItemType deleteItemRequest) { DeleteItemResponseType response = this.exchangeServiceBinding.DeleteItem(deleteItemRequest); Site.Assert.IsNotNull(response, "If the operation is successful, the response should not be null."); // SOAP version is set to 1.1, if a response can be received from server, then it means SOAP 1.1 is supported. this.VerifySoapVersion(); // Verify transport type related requirement. this.VerifyTransportType(); this.VerifyServerVersionInfo(this.exchangeServiceBinding.ServerVersionInfoValue, this.exchangeServiceBinding.IsSchemaValidated); this.VerifyDeleteItemResoponse(response, this.exchangeServiceBinding.IsSchemaValidated); return(response); }
/// <summary> /// Delete the given message permanatly. /// </summary> /// <param name="messageId"></param> public void DeleteMessage(ItemIdType messageId) { var binding = ChannelHelper.BuildChannel(hostname, username, password); var deleteItemRequest = new DeleteItemType { ItemIds = new BaseItemIdType[] { messageId }, DeleteType = DisposalType.HardDelete }; DeleteItemResponseType deleteResponse = binding.DeleteItem(deleteItemRequest); if (deleteResponse.ResponseMessages.Items[0].ResponseClass == ResponseClassType.Error) { throw new Exception(deleteResponse.ResponseMessages.Items[0].MessageText); } }
/// <summary> /// Delete a specific message. /// </summary> /// <param name="messageId">The Id of the message to be deleted.</param> /// <returns>True if the delete operation success, otherwise false.</returns> protected bool DeleteMessage(string messageId) { DeleteItemType deleteItemRequest = new DeleteItemType() { DeleteType = DisposalType.HardDelete, ItemIds = new BaseItemIdType[] { new ItemIdType() { Id = messageId } } }; DeleteItemResponseType deleteItemResponse = this.COREAdapter.DeleteItem(deleteItemRequest); ResponseMessageType responseMessage = deleteItemResponse.ResponseMessages.Items[0] as ResponseMessageType; return(responseMessage.ResponseClass == ResponseClassType.Success); }
private void DeleteItem(BaseItemIdType itemId) { DeleteItemType deleteItemRequest = new DeleteItemType(); deleteItemRequest.DeleteType = DisposalType.HardDelete; deleteItemRequest.AffectedTaskOccurrences = AffectedTaskOccurrencesType.SpecifiedOccurrenceOnly; deleteItemRequest.AffectedTaskOccurrencesSpecified = true; deleteItemRequest.SendMeetingCancellations = CalendarItemCreateOrDeleteOperationType.SendToNone; deleteItemRequest.SendMeetingCancellationsSpecified = true; deleteItemRequest.ItemIds = new BaseItemIdType[] { itemId }; DeleteItemResponseType response = Service.DeleteItem(deleteItemRequest); ResponseMessageType responseMessage = response.ResponseMessages.Items[0]; if (responseMessage.ResponseCode != ResponseCodeType.NoError) { throw new Exception("DeleteItem failed with response code " + responseMessage.ResponseCode); } }
public void MSOXWSMSG_S04_TC01_MoveMessage() { #region Create message CreateItemType createItemRequest = GetCreateItemType(MessageDispositionType.SaveOnly, DistinguishedFolderIdNameType.drafts); CreateItemResponseType createItemResponse = this.MSGAdapter.CreateItem(createItemRequest); Site.Assert.IsTrue(this.VerifyCreateItemResponse(createItemResponse, MessageDispositionType.SaveOnly), @"Server should return success for creating the email messages."); this.infoItems = TestSuiteHelper.GetInfoItemsInResponse(createItemResponse); this.firstItemOfFirstInfoItem = TestSuiteHelper.GetItemTypeItemFromInfoItemsByIndex(this.infoItems, 0, 0); // Save the ItemId of message responseMessageItem got from the createItem response. ItemIdType itemIdType = new ItemIdType(); Site.Assert.IsNotNull(this.firstItemOfFirstInfoItem.ItemId, @"The ItemId property of the first item should not be null."); itemIdType.Id = this.firstItemOfFirstInfoItem.ItemId.Id; itemIdType.ChangeKey = this.firstItemOfFirstInfoItem.ItemId.ChangeKey; #endregion #region Move message MoveItemType moveItemRequest = new MoveItemType { ItemIds = new ItemIdType[] { itemIdType }, // Set target folder to junk email folder. ToFolderId = new TargetFolderIdType { Item = new DistinguishedFolderIdType { Id = DistinguishedFolderIdNameType.junkemail } } }; MoveItemResponseType moveItemResponse = this.MSGAdapter.MoveItem(moveItemRequest); Site.Assert.IsTrue(this.VerifyResponse(moveItemResponse), @"Server should return success for moving the email messages."); this.infoItems = TestSuiteHelper.GetInfoItemsInResponse(moveItemResponse); this.firstItemOfFirstInfoItem = TestSuiteHelper.GetItemTypeItemFromInfoItemsByIndex(this.infoItems, 0, 0); Site.Assert.IsNotNull(this.infoItems, @"InfoItems in the returned response should not be null."); Site.Assert.IsNotNull(this.firstItemOfFirstInfoItem, @"The first item of the array of ItemType type returned from server response should not be null."); // Save the ItemId of message responseMessageItem got from the moveItem response. ItemIdType moveItemIdType = new ItemIdType(); Site.Assert.IsNotNull(this.firstItemOfFirstInfoItem.ItemId, @"The ItemId property of the first item should not be null."); moveItemIdType.Id = this.firstItemOfFirstInfoItem.ItemId.Id; moveItemIdType.ChangeKey = this.firstItemOfFirstInfoItem.ItemId.ChangeKey; // Verify whether the message is moved to junkemail folder. string userName = Common.GetConfigurationPropertyValue("Sender", this.Site); string password = Common.GetConfigurationPropertyValue("SenderPassword", this.Site); string domain = Common.GetConfigurationPropertyValue("Domain", this.Site); bool findItemInDrafts = this.IsItemAvailableAfterMoveOrDelete(userName, password, domain, "drafts", this.Subject, "itemSubject"); Site.Assert.IsFalse(findItemInDrafts, "The item should not be found in the drafts folder of Sender."); bool findItemInJunkemail = this.SearchItems(Role.Sender, "junkemail", this.Subject, "itemSubject"); Site.Assert.IsTrue(findItemInJunkemail, "The item should be found in the junkemail folder of Sender."); #region Verify the requirements about MoveItem // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMSG_R161"); // Verify MS-OXWSMSG requirement: MS-OXWSMSG_R161 Site.CaptureRequirementIfIsNotNull( moveItemResponse, 161, @"[In MoveItem] The protocol client sends a MoveItemSoapIn request WSDL message, and the protocol server responds with a MoveItemSoapOut response WSDL message."); Site.Assert.IsNotNull(this.infoItems[0].ResponseClass, @"The ResponseClass property of the first item of infoItems instance should not be null."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMSG_R162"); // Verify MS-OXWSMSG requirement: MS-OXWSMSG_R162 Site.CaptureRequirementIfAreEqual <ResponseClassType>( ResponseClassType.Success, this.infoItems[0].ResponseClass, 162, @"[In MoveItem] If the MoveItem WSDL operation request is successful, the server returns a MoveItemResponse element, as specified in [MS-OXWSCORE] section 3.1.4.7.2.2, with the ResponseClass attribute, as specified in [MS-OXWSCDATA] section 2.2.4.67, of the MoveItemResponseMessage element, as specified in [MS-OXWSCDATA] section 2.2.4.12, set to ""Success"". "); Site.Assert.IsNotNull(this.infoItems[0].ResponseCode, @"The ResponseCode property of the first item of infoItems instance should not be null."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMSG_R163"); // Verify MS-OXWSMSG requirement: MS-OXWSMSG_R163 Site.CaptureRequirementIfAreEqual <ResponseCodeType>( ResponseCodeType.NoError, this.infoItems[0].ResponseCode, 163, @"[In MoveItem] [A successful MoveItem operation request returns a MoveItemResponse element] The ResponseCode element, as specified in [MS-OXWSCDATA] section 2.2.4.67, of the MoveItemResponseMessage element is set to ""NoError"". "); #endregion #endregion #region Delete the moved message DeleteItemType deleteItemRequest = new DeleteItemType { ItemIds = new ItemIdType[] { moveItemIdType } }; DeleteItemResponseType deleteItemResponse = this.MSGAdapter.DeleteItem(deleteItemRequest); Site.Assert.IsTrue(this.VerifyResponse(deleteItemResponse), @"Server should return success for deleting the email messages."); #endregion }
public void MSOXWSMSG_S04_TC02_MoveMessageUnsuccessful() { #region Create message CreateItemType createItemRequest = GetCreateItemType(MessageDispositionType.SaveOnly, DistinguishedFolderIdNameType.drafts); CreateItemResponseType createItemResponse = this.MSGAdapter.CreateItem(createItemRequest); Site.Assert.IsTrue(this.VerifyCreateItemResponse(createItemResponse, MessageDispositionType.SaveOnly), @"Server should return success for creating the email messages."); this.infoItems = TestSuiteHelper.GetInfoItemsInResponse(createItemResponse); this.firstItemOfFirstInfoItem = TestSuiteHelper.GetItemTypeItemFromInfoItemsByIndex(this.infoItems, 0, 0); // Save the ItemId of message responseMessageItem got from the createItem response. ItemIdType itemIdType = new ItemIdType(); Site.Assert.IsNotNull(this.firstItemOfFirstInfoItem.ItemId, @"The ItemId property of the first item should not be null."); itemIdType.Id = this.firstItemOfFirstInfoItem.ItemId.Id; itemIdType.ChangeKey = this.firstItemOfFirstInfoItem.ItemId.ChangeKey; #endregion #region Delete the message created DeleteItemType deleteItemRequest = new DeleteItemType { ItemIds = new ItemIdType[] { this.firstItemOfFirstInfoItem.ItemId } }; DeleteItemResponseType deleteItemResponse = this.MSGAdapter.DeleteItem(deleteItemRequest); Site.Assert.IsTrue(this.VerifyResponse(deleteItemResponse), @"Server should return success for deleting the email messages."); #endregion #region Move message MoveItemType moveItemRequest = new MoveItemType { ItemIds = new ItemIdType[] { itemIdType }, // Set target folder to junk email folder. ToFolderId = new TargetFolderIdType { Item = new DistinguishedFolderIdType { Id = DistinguishedFolderIdNameType.junkemail } } }; MoveItemResponseType moveItemResponse = this.MSGAdapter.MoveItem(moveItemRequest); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMSG_R163001"); this.Site.CaptureRequirementIfAreEqual <ResponseClassType>( ResponseClassType.Error, moveItemResponse.ResponseMessages.Items[0].ResponseClass, 163001, @"[In MoveItem] If the MoveItem WSDL operation request is not successful, it returns a MoveItemResponse element with the ResponseClass attribute of the MoveItemResponseMessage element set to ""Error"". "); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMSG_R163002"); this.Site.CaptureRequirementIfIsTrue( System.Enum.IsDefined(typeof(ResponseCodeType), moveItemResponse.ResponseMessages.Items[0].ResponseCode), 163002, @"[In MoveItem] [A unsuccessful MoveItem operation request returns a MoveItemResponse element] The ResponseCode element of the MoveItemResponseMessage element is set to one of the common errors defined in [MS-OXWSCDATA] section 2.2.5.24."); #endregion }
/// <remarks/> public void DeleteItemAsync(DeleteItemType DeleteItem1, object userState) { if ((this.DeleteItemOperationCompleted == null)) { this.DeleteItemOperationCompleted = new System.Threading.SendOrPostCallback(this.OnDeleteItemOperationCompleted); } this.InvokeAsync("DeleteItem", new object[] { DeleteItem1}, this.DeleteItemOperationCompleted, userState); }
/// <remarks/> public void DeleteItemAsync(DeleteItemType DeleteItem1) { this.DeleteItemAsync(DeleteItem1, null); }
/// <remarks/> public System.IAsyncResult BeginDeleteItem(DeleteItemType DeleteItem1, System.AsyncCallback callback, object asyncState) { return this.BeginInvoke("DeleteItem", new object[] { DeleteItem1}, callback, asyncState); }
/// <summary> /// Deletes all items and sub folders from the specified folder. /// </summary> /// <param name="folderName">Name of the specified parent folder.</param> /// <param name="needVerify">If need to verify the subfolders,when false,it will cleanup all the folders without verify</param> /// <returns>If the specified folder is cleaned up successfully, return true; otherwise, return false.</returns> private bool CleanupFolder(DistinguishedFolderIdNameType folderName, bool needVerify = true) { bool isAllItemsAndFoldersDeleted = false; ItemType[] items = this.FindAllItems(folderName); // Create a request for the DeleteItem operation. DeleteItemType deleteItemRequest = new DeleteItemType(); // The item is permanently removed from the store. deleteItemRequest.DeleteType = DisposalType.HardDelete; // Do not send meeting cancellations. deleteItemRequest.SendMeetingCancellations = CalendarItemCreateOrDeleteOperationType.SendToNone; deleteItemRequest.SendMeetingCancellationsSpecified = true; if (items != null) { foreach (ItemType currentItem in items) { if (currentItem.GetType() == typeof(TaskType)) { deleteItemRequest.AffectedTaskOccurrencesSpecified = true; deleteItemRequest.AffectedTaskOccurrences = AffectedTaskOccurrencesType.AllOccurrences; } deleteItemRequest.ItemIds = new BaseItemIdType[] { currentItem.ItemId }; // Invoke the delete item operation. DeleteItemResponseType response = this.exchangeServiceBinding.DeleteItem(deleteItemRequest); Site.Assert.AreEqual <ResponseClassType>( ResponseClassType.Success, response.ResponseMessages.Items[0].ResponseClass, "The delete item operation should execute successfully."); } } // Find all sub folders in the specified folder. BaseFolderType[] folders = this.FindAllSubFolders(folderName); if (folders.Length != 0) { foreach (BaseFolderType currentFolder in folders) { if (needVerify) { bool isCreatedByCase = false; AdapterHelper.CreatedFolders.ForEach(r => { if (r.FolderId.Id == currentFolder.FolderId.Id) { isCreatedByCase = true; } }); if (!isCreatedByCase) { continue; } } FolderIdType responseFolderId = currentFolder.FolderId; FolderIdType folderId = new FolderIdType(); folderId.Id = responseFolderId.Id; DeleteFolderType deleteFolderRequest = new DeleteFolderType(); deleteFolderRequest.DeleteType = DisposalType.HardDelete; deleteFolderRequest.FolderIds = new BaseFolderIdType[1]; deleteFolderRequest.FolderIds[0] = folderId; // Send the request and get the response. DeleteFolderResponseType deleteFolderResponse = this.exchangeServiceBinding.DeleteFolder(deleteFolderRequest); // Delete folder operation should return response info. if (deleteFolderResponse.ResponseMessages.Items[0] != null) { Site.Assert.AreEqual <ResponseClassType>( ResponseClassType.Success, deleteFolderResponse.ResponseMessages.Items[0].ResponseClass, "The delete folder operation should be successful."); } } } // Invoke the FindItem operation. items = this.FindAllItems(folderName); // Invoke the FindFolder operation. folders = this.FindAllSubFolders(folderName); // If neither items and sub folders could be found, the folder has been cleaned up successfully. bool allFoldersBelongstoSys = true; foreach (BaseFolderType folder in folders) { bool find = false; AdapterHelper.CreatedFolders.ForEach(r => { if (r.FolderId.Id == folder.FolderId.Id) { find = true; } }); if (find) { allFoldersBelongstoSys = false; break; } } if (items == null && (folders.Length == 0 || allFoldersBelongstoSys)) { isAllItemsAndFoldersDeleted = true; } return(isAllItemsAndFoldersDeleted); }
public void MSOXWSMSG_S03_TC01_CopyMessage() { #region Create message CreateItemType createItemRequest = GetCreateItemType(MessageDispositionType.SaveOnly, DistinguishedFolderIdNameType.drafts); CreateItemResponseType createItemResponse = this.MSGAdapter.CreateItem(createItemRequest); Site.Assert.IsTrue(this.VerifyCreateItemResponse(createItemResponse, MessageDispositionType.SaveOnly), @"Server should return success for creating the email messages."); this.infoItems = TestSuiteHelper.GetInfoItemsInResponse(createItemResponse); this.firstItemOfFirstInfoItem = TestSuiteHelper.GetItemTypeItemFromInfoItemsByIndex(this.infoItems, 0, 0); // Save the ItemId of message responseMessageItem got from the createItem response. ItemIdType itemIdType = new ItemIdType(); Site.Assert.IsNotNull(this.firstItemOfFirstInfoItem.ItemId, @"The ItemId property of the first item should not be null."); itemIdType.Id = this.firstItemOfFirstInfoItem.ItemId.Id; itemIdType.ChangeKey = this.firstItemOfFirstInfoItem.ItemId.ChangeKey; #endregion #region Copy message CopyItemType copyItemRequest = new CopyItemType { ItemIds = new ItemIdType[] { itemIdType }, // Save the copy message to inbox folder. ToFolderId = new TargetFolderIdType { Item = new DistinguishedFolderIdType { Id = DistinguishedFolderIdNameType.inbox } } }; CopyItemResponseType copyItemResponse = this.MSGAdapter.CopyItem(copyItemRequest); Site.Assert.IsTrue(this.VerifyResponse(copyItemResponse), @"Server should return success for copying the email messages."); this.infoItems = TestSuiteHelper.GetInfoItemsInResponse(copyItemResponse); this.firstItemOfFirstInfoItem = TestSuiteHelper.GetItemTypeItemFromInfoItemsByIndex(this.infoItems, 0, 0); Site.Assert.IsNotNull(this.infoItems, @"InfoItems in the returned response should not be null."); Site.Assert.IsNotNull(this.firstItemOfFirstInfoItem, @"The first item of the array of ItemType type from server response should not be null."); // Save the ItemId of message responseMessageItem got from the copyItem response. ItemIdType copyItemIdType = new ItemIdType(); Site.Assert.IsNotNull(this.firstItemOfFirstInfoItem.ItemId, @"The ItemId property of the first item should not be null."); copyItemIdType.Id = this.firstItemOfFirstInfoItem.ItemId.Id; copyItemIdType.ChangeKey = this.firstItemOfFirstInfoItem.ItemId.ChangeKey; #region Verify the requirements about CopyItem // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMSG_R168"); // Verify MS-OXWSMSG requirement: MS-OXWSMSG_R168 Site.CaptureRequirementIfIsNotNull( copyItemResponse, 168, @"[In CopyItem] The protocol client sends a CopyItemSoapIn request WSDL message, and the protocol server responds with a CopyItemSoapOut response WSDL message."); Site.Assert.IsNotNull(this.infoItems[0].ResponseClass, @"The ResponseClass property of the first item of infoItems instance should not be null."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMSG_R169"); // Verify MS-OXWSMSG requirement: MS-OXWSMSG_R169 Site.CaptureRequirementIfAreEqual <ResponseClassType>( ResponseClassType.Success, copyItemResponse.ResponseMessages.Items[0].ResponseClass, 169, @"[In CopyItem] If the CreateItem WSDL operation request is successful, the server returns a CreateItemResponse element, as specified in [MS-OXWSCORE] section 3.1.4.2.2.2, with the ResponseClass attribute, as specified in [MS-OXWSCDATA] section 2.2.4.67, of the CreateItemResponseMessage element, as specified in [MS-OXWSCDATA] section 2.2.4.12, set to ""Success"". "); Site.Assert.IsNotNull(this.infoItems[0].ResponseCode, @"The ResponseCode property of the first item of infoItems instance should not be null."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMSG_R170"); // Verify MS-OXWSMSG requirement: MS-OXWSMSG_R170 Site.CaptureRequirementIfAreEqual <ResponseCodeType>( ResponseCodeType.NoError, copyItemResponse.ResponseMessages.Items[0].ResponseCode, 170, @"[In CopyItem] [A successful CopyItem operation request returns a CopyItemResponse element] The ResponseCode element, as specified in [MS-OXWSCDATA] section 2.2.4.67, of the CreateItemResponseMessage element is set to ""NoError"". "); #endregion #endregion #region Delete the copied Email messages DeleteItemType deleteItemRequest = new DeleteItemType { ItemIds = new ItemIdType[] { itemIdType, copyItemIdType } }; DeleteItemResponseType deleteItemResponse = this.MSGAdapter.DeleteItem(deleteItemRequest); Site.Assert.IsTrue(this.VerifyMultipleResponse(deleteItemResponse), @"Server should return success for deleting the email messages."); #endregion }
/// <summary> /// Deletes items on the server. /// </summary> /// <param name="deleteItemRequest">Request message of "DeleteItem" operation.</param> /// <returns>Response message of "DeleteItem" operation.</returns> public DeleteItemResponseType DeleteItem(DeleteItemType deleteItemRequest) { DeleteItemResponseType deleteItemResponse = this.exchangeServiceBinding.DeleteItem(deleteItemRequest); return(deleteItemResponse); }
public void MSOXWSFOLD_S05_TC05_SoftEmptyFolder() { Site.Assume.IsTrue(Common.IsRequirementEnabled(5664, this.Site), "Exchange Server 2007 and the initial release version of Exchange Server 2010 do not support EmptyFolder operation"); Site.Assume.IsTrue(Common.IsRequirementEnabled(4000, this.Site), "Exchange Server 2007 and the initial release version of Exchange Server 2010 do not include enumeration value recoverableitemsdeletions"); #region Create a new folder in the inbox folder // CreateFolder request. CreateFolderType createFolderRequest = this.GetCreateFolderRequest(DistinguishedFolderIdNameType.inbox.ToString(), new string[] { "Custom Folder" }, new string[] { "IPF.MyCustomFolderClass" }, null); // Create a new folder. CreateFolderResponseType createFolderResponse = this.FOLDAdapter.CreateFolder(createFolderRequest); // Check the response. Common.CheckOperationSuccess(createFolderResponse, 1, this.Site); // Save the new created folder's folder id. FolderIdType newFolderId = ((FolderInfoResponseMessageType)createFolderResponse.ResponseMessages.Items[0]).Folders[0].FolderId; this.NewCreatedFolderIds.Add(newFolderId); #endregion #region Create an item string itemName = Common.GenerateResourceName(this.Site, "Test Mail"); // Create an item in the new created folder. ItemIdType itemId = this.CreateItem(Common.GetConfigurationPropertyValue("User1Name", this.Site) + "@" + Common.GetConfigurationPropertyValue("Domain", this.Site), newFolderId.Id, itemName); Site.Assert.IsNotNull(itemId, "Item should be created successfully!"); #endregion #region Get the new created folder // GetFolder request. GetFolderType getNewFolderRequest = this.GetGetFolderRequest(DefaultShapeNamesType.AllProperties, newFolderId); // Get the new created folder. GetFolderResponseType getFolderResponse = this.FOLDAdapter.GetFolder(getNewFolderRequest); // Check the response. Common.CheckOperationSuccess(getFolderResponse, 1, this.Site); #endregion #region Empty the created folder EmptyFolderResponseType emptyFolderResponse = this.CallEmptyFolderOperation(newFolderId, DisposalType.SoftDelete, true); Common.CheckOperationSuccess(emptyFolderResponse, 1, this.Site); #endregion #region Find the item ItemIdType findItemID = this.FindItem(DistinguishedFolderIdNameType.recoverableitemsdeletions.ToString(), itemName); // Add the debug information this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSFOLD_R37803"); this.Site.CaptureRequirementIfIsNotNull( findItemID, 37803, @"[In m:EmptyFolderType Complex Type ]DeleteType which value is SoftDelete specifies that an item or folder is moved to the dumpster if the dumpster is enabled."); DeleteItemType deleteItemRequest = new DeleteItemType(); deleteItemRequest.ItemIds = new BaseItemIdType[] { findItemID }; DeleteItemResponseType deleteItemResponse = this.COREAdapter.DeleteItem(deleteItemRequest); Common.CheckOperationSuccess(deleteItemResponse, 1, this.Site); #endregion }
public void MSOXWSMSG_S05_TC01_SendMessage() { #region Create the message CreateItemType createItemRequest = GetCreateItemType(MessageDispositionType.SaveOnly, DistinguishedFolderIdNameType.drafts); CreateItemResponseType createItemResponse = this.MSGAdapter.CreateItem(createItemRequest); Site.Assert.IsTrue(this.VerifyCreateItemResponse(createItemResponse, MessageDispositionType.SaveOnly), @"Server should return success for creating the email messages."); this.infoItems = TestSuiteHelper.GetInfoItemsInResponse(createItemResponse); this.firstItemOfFirstInfoItem = TestSuiteHelper.GetItemTypeItemFromInfoItemsByIndex(this.infoItems, 0, 0); // Save the ItemId of message responseMessageItem got from the createItem response. Site.Assert.IsNotNull(this.firstItemOfFirstInfoItem.ItemId, @"The ItemId property of the first item should not be null."); ItemIdType itemIdType = new ItemIdType(); itemIdType.Id = this.firstItemOfFirstInfoItem.ItemId.Id; itemIdType.ChangeKey = this.firstItemOfFirstInfoItem.ItemId.ChangeKey; #endregion #region Send the message SendItemType sendItemRequest = new SendItemType { ItemIds = new ItemIdType[] { itemIdType }, SaveItemToFolder = true, // Save the message copy in sent items folder. SavedItemFolderId = new TargetFolderIdType { Item = new DistinguishedFolderIdType { Id = DistinguishedFolderIdNameType.sentitems } } }; SendItemResponseType sendItemResponse = this.MSGAdapter.SendItem(sendItemRequest); Site.Assert.IsTrue(this.VerifyResponse(sendItemResponse), @"Server should return success for sending the email messages."); Site.Assert.IsNotNull(sendItemResponse.ResponseMessages.Items, @"Items in the returned response should not be null."); #region Verify the requirements about SendItem // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMSG_R177"); // Verify MS-OXWSMSG requirement: MS-OXWSMSG_R177 Site.CaptureRequirementIfIsNotNull( sendItemResponse, 177, @"[In SendItem] The protocol client sends a SendItemSoapIn request WSDL message, and the protocol server responds with a SendItemSoapOut response WSDL message."); Site.Assert.IsNotNull(sendItemResponse.ResponseMessages.Items[0].ResponseClass, @"The ResponseClass property of the first item of infoItems instance should not be null."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMSG_R178"); // Verify MS-OXWSMSG requirement: MS-OXWSMSG_R178 Site.CaptureRequirementIfAreEqual <ResponseClassType>( ResponseClassType.Success, sendItemResponse.ResponseMessages.Items[0].ResponseClass, 178, @"[In SendItem] A successful SendItem operation request returns a SendItemResponse element with the ResponseClass attribute of the SendItemResponseMessage element set to ""Success""."); Site.Assert.IsNotNull(sendItemResponse.ResponseMessages.Items[0].ResponseCode, @"The ResponseCode property of the first item of infoItems instance should not be null."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMSG_R179"); // Verify MS-OXWSMSG requirement: MS-OXWSMSG_R179 Site.CaptureRequirementIfAreEqual <ResponseCodeType>( ResponseCodeType.NoError, sendItemResponse.ResponseMessages.Items[0].ResponseCode, 179, @"[In SendItem] [A successful SendItem operation request returns a SendItemResponse element] The ResponseCode element of the SendItemResponse element is set to ""NoError""."); #endregion #endregion #region Create the invalid message for SendItem operation without ToRecipients element CreateItemType createItemRequestFailed = new CreateItemType { MessageDisposition = MessageDispositionType.SaveOnly, // MessageDispositionSpecified value needs to be set. MessageDispositionSpecified = true, SavedItemFolderId = new TargetFolderIdType { Item = new DistinguishedFolderIdType { Id = DistinguishedFolderIdNameType.drafts } }, Items = new NonEmptyArrayOfAllItemsType { Items = new MessageType[] { new MessageType { Sender = new SingleRecipientType { Item = new EmailAddressType { EmailAddress = this.Sender } }, Subject = this.Subject, } } }, }; CreateItemResponseType createItemResponseFailed = this.MSGAdapter.CreateItem(createItemRequestFailed); Site.Assert.IsTrue(this.VerifyResponse(createItemResponseFailed), @"Server should return success for creating the email messages."); this.infoItems = TestSuiteHelper.GetInfoItemsInResponse(createItemResponseFailed); this.firstItemOfFirstInfoItem = TestSuiteHelper.GetItemTypeItemFromInfoItemsByIndex(this.infoItems, 0, 0); Site.Assert.IsNotNull(this.infoItems, @"InfoItems in the returned response should not be null."); Site.Assert.IsNotNull(this.firstItemOfFirstInfoItem, @"The first item of the array of ItemType type returned from server response should not be null."); // Save the ItemId of message responseMessageItem got from the createItem response. Site.Assert.IsNotNull(this.firstItemOfFirstInfoItem.ItemId, @"The ItemId property of the first item should not be null."); itemIdType.Id = this.firstItemOfFirstInfoItem.ItemId.Id; itemIdType.ChangeKey = this.firstItemOfFirstInfoItem.ItemId.ChangeKey; #endregion #region Send the message without ToRecipients element SendItemType sendItemRequestFailed = new SendItemType { // Set to invalid message's ItemId. ItemIds = new ItemIdType[] { itemIdType }, SaveItemToFolder = true, SavedItemFolderId = new TargetFolderIdType { Item = new DistinguishedFolderIdType { Id = DistinguishedFolderIdNameType.sentitems } } }; SendItemResponseType sendItemResponseFailed = this.MSGAdapter.SendItem(sendItemRequestFailed); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSMSG_R31"); // Verify MS-OXWSMSG requirement: MS-OXWSMSG_R31 Site.CaptureRequirementIfAreNotEqual <ResponseClassType>( ResponseClassType.Success, sendItemResponseFailed.ResponseMessages.Items[0].ResponseClass, 31, @"[In t:MessageType Complex Type] [ToRecipients element] This element is required for sending a message."); #endregion #region Delete the invalid message DeleteItemType deleteItemRequest = new DeleteItemType { // Set to invalid message's ItemId. ItemIds = new ItemIdType[] { itemIdType } }; DeleteItemResponseType deleteItemResponse = this.MSGAdapter.DeleteItem(deleteItemRequest); Site.Assert.IsTrue(this.VerifyResponse(deleteItemResponse), @"Server should return success for deleting the email messages."); #endregion #region Clean up Sender's sentitems folder and Recipient1's inbox folder bool isClear = this.MSGSUTControlAdapter.CleanupFolders( Common.GetConfigurationPropertyValue("Sender", this.Site), Common.GetConfigurationPropertyValue("SenderPassword", this.Site), this.Domain, this.Subject, "sentitems"); Site.Assert.IsTrue(isClear, "Sender's sentitems folder should be cleaned up."); isClear = this.MSGSUTControlAdapter.CleanupFolders( Common.GetConfigurationPropertyValue("Recipient1", this.Site), Common.GetConfigurationPropertyValue("Recipient1Password", this.Site), this.Domain, this.Subject, "inbox"); Site.Assert.IsTrue(isClear, "Recipient1's inbox folder should be cleaned up."); #endregion }
public void MSOXWSMSG_S06_TC01_OperateMultipleMessages() { #region Create multiple message string subject = Common.GenerateResourceName(this.Site, Common.GetConfigurationPropertyValue("Subject", Site), 0); string anotherSubject = Common.GenerateResourceName(this.Site, Common.GetConfigurationPropertyValue("Subject", Site), 1); CreateItemType createItemRequest = new CreateItemType { MessageDisposition = MessageDispositionType.SaveOnly, // MessageDispositionSpecified value needs to be set. MessageDispositionSpecified = true, SavedItemFolderId = new TargetFolderIdType { Item = new DistinguishedFolderIdType { Id = DistinguishedFolderIdNameType.drafts } }, Items = new NonEmptyArrayOfAllItemsType { // Create an responseMessageItem with two MessageType instances. Items = new MessageType[] { new MessageType { Sender = new SingleRecipientType { Item = new EmailAddressType { EmailAddress = this.Sender } }, ToRecipients = new EmailAddressType[] { new EmailAddressType { EmailAddress = this.Recipient1 } }, Subject = subject, }, new MessageType { Sender = new SingleRecipientType { Item = new EmailAddressType { EmailAddress = this.Sender } }, ToRecipients = new EmailAddressType[] { new EmailAddressType { EmailAddress = this.Recipient2 } }, Subject = anotherSubject, } } }, }; CreateItemResponseType createItemResponse = this.MSGAdapter.CreateItem(createItemRequest); Site.Assert.IsTrue(this.VerifyMultipleResponse(createItemResponse), @"Server should return success for creating the email messages."); this.infoItems = TestSuiteHelper.GetInfoItemsInResponse(createItemResponse); this.firstItemOfFirstInfoItem = TestSuiteHelper.GetItemTypeItemFromInfoItemsByIndex(this.infoItems, 0, 0); Site.Assert.IsNotNull(this.infoItems, @"InfoItems in the returned response should not be null."); Site.Assert.IsNotNull(this.firstItemOfFirstInfoItem, @"The first item of the array of ItemType type returned from server response should not be null."); // Save the first ItemId of message responseMessageItem got from the createItem response. Site.Assert.IsNotNull(this.firstItemOfFirstInfoItem.ItemId, @"The ItemId property of the first item should not be null."); ItemIdType itemIdType1 = new ItemIdType(); itemIdType1.Id = this.firstItemOfFirstInfoItem.ItemId.Id; itemIdType1.ChangeKey = this.firstItemOfFirstInfoItem.ItemId.ChangeKey; // Save the second ItemId. this.firstItemOfSecondInfoItem = TestSuiteHelper.GetItemTypeItemFromInfoItemsByIndex(this.infoItems, 1, 0); Site.Assert.IsNotNull(this.firstItemOfSecondInfoItem, @"The second item of the array of ItemType type returned from server response should not be null."); Site.Assert.IsNotNull(this.firstItemOfSecondInfoItem.ItemId, @"The ItemId property of the second item should not be null."); ItemIdType itemIdType2 = new ItemIdType(); itemIdType2.Id = this.firstItemOfSecondInfoItem.ItemId.Id; itemIdType2.ChangeKey = this.firstItemOfSecondInfoItem.ItemId.ChangeKey; #endregion #region Get the multiple messages which created GetItemType getItemRequest = new GetItemType { // Set the two ItemIds got from CreateItem response. ItemIds = new ItemIdType[] { itemIdType1, itemIdType2 }, ItemShape = new ItemResponseShapeType { BaseShape = DefaultShapeNamesType.AllProperties, } }; GetItemResponseType getItemResponse = this.MSGAdapter.GetItem(getItemRequest); Site.Assert.IsTrue(this.VerifyMultipleResponse(getItemResponse), @"Server should return success for creating the email messages."); #endregion #region Update the multiple messages which created UpdateItemType updateItemRequest = new UpdateItemType { MessageDisposition = MessageDispositionType.SaveOnly, // MessageDispositionSpecified value needs to be set. MessageDispositionSpecified = true, // Create two ItemChangeType instances. ItemChanges = new ItemChangeType[] { new ItemChangeType { Item = itemIdType1, Updates = new ItemChangeDescriptionType[] { new SetItemFieldType { Item = new PathToUnindexedFieldType { FieldURI = UnindexedFieldURIType.messageToRecipients }, // Update ToRecipients property of the first message. Item1 = new MessageType { ToRecipients = new EmailAddressType[] { new EmailAddressType { EmailAddress = this.Recipient2 } } } }, } }, new ItemChangeType { Item = itemIdType2, Updates = new ItemChangeDescriptionType[] { new SetItemFieldType { Item = new PathToUnindexedFieldType { FieldURI = UnindexedFieldURIType.messageToRecipients }, // Update ToRecipients property of the second message. Item1 = new MessageType { ToRecipients = new EmailAddressType[] { new EmailAddressType { EmailAddress = this.Recipient1 } } } }, } } } }; UpdateItemResponseType updateItemResponse = this.MSGAdapter.UpdateItem(updateItemRequest); Site.Assert.IsTrue(this.VerifyMultipleResponse(updateItemResponse), @"Server should return success for updating the email messages."); this.infoItems = TestSuiteHelper.GetInfoItemsInResponse(updateItemResponse); this.firstItemOfFirstInfoItem = TestSuiteHelper.GetItemTypeItemFromInfoItemsByIndex(this.infoItems, 0, 0); Site.Assert.IsNotNull(this.infoItems, @"InfoItems in the returned response should not be null."); Site.Assert.IsNotNull(this.firstItemOfFirstInfoItem, @"The first item of the array of ItemType type returned from server response should not be null."); // Save the ItemId of the first message responseMessageItem got from the UpdateItem response. Site.Assert.IsNotNull(this.firstItemOfFirstInfoItem.ItemId, @"The ItemId property of the first item should not be null."); itemIdType1.Id = this.firstItemOfFirstInfoItem.ItemId.Id; itemIdType1.ChangeKey = this.firstItemOfFirstInfoItem.ItemId.ChangeKey; // Save the ItemId of the second message responseMessageItem got from the UpdateItem response. this.firstItemOfSecondInfoItem = TestSuiteHelper.GetItemTypeItemFromInfoItemsByIndex(this.infoItems, 1, 0); Site.Assert.IsNotNull(this.firstItemOfSecondInfoItem, @"The second item of the array of ItemType type returned from server response should not be null."); Site.Assert.IsNotNull(this.firstItemOfSecondInfoItem.ItemId, @"The ItemId property of the second item should not be null."); itemIdType2.Id = this.firstItemOfSecondInfoItem.ItemId.Id; itemIdType2.ChangeKey = this.firstItemOfSecondInfoItem.ItemId.ChangeKey; #endregion #region Copy the updated multiple message to junkemail CopyItemType copyItemRequest = new CopyItemType { ItemIds = new ItemIdType[] { itemIdType1, itemIdType2, }, // Copy the message to junk email folder. ToFolderId = new TargetFolderIdType { Item = new DistinguishedFolderIdType { Id = DistinguishedFolderIdNameType.junkemail } } }; CopyItemResponseType copyItemResponse = this.MSGAdapter.CopyItem(copyItemRequest); Site.Assert.IsTrue(this.VerifyMultipleResponse(copyItemResponse), @"Server should return success for copying the email messages."); this.infoItems = TestSuiteHelper.GetInfoItemsInResponse(copyItemResponse); this.firstItemOfFirstInfoItem = TestSuiteHelper.GetItemTypeItemFromInfoItemsByIndex(this.infoItems, 0, 0); Site.Assert.IsNotNull(this.infoItems, @"InfoItems in the returned response should not be null."); Site.Assert.IsNotNull(this.firstItemOfFirstInfoItem, @"The first item of the array of ItemType type returned from server response should not be null."); // Save the ItemId of the first message responseMessageItem got from the CopyItem response. Site.Assert.IsNotNull(this.firstItemOfFirstInfoItem.ItemId, @"The ItemId property of the first item should not be null."); ItemIdType copyItemIdType1 = new ItemIdType(); copyItemIdType1.Id = this.firstItemOfFirstInfoItem.ItemId.Id; copyItemIdType1.ChangeKey = this.firstItemOfFirstInfoItem.ItemId.ChangeKey; // Save the ItemId of the second message responseMessageItem got from the CopyItem response. this.firstItemOfSecondInfoItem = TestSuiteHelper.GetItemTypeItemFromInfoItemsByIndex(this.infoItems, 1, 0); Site.Assert.IsNotNull(this.firstItemOfSecondInfoItem, @"The second item of the array of ItemType type returned from server response should not be null."); Site.Assert.IsNotNull(this.firstItemOfSecondInfoItem.ItemId, @"The ItemId property of the second item should not be null."); ItemIdType copyItemIdType2 = new ItemIdType(); copyItemIdType2.Id = this.firstItemOfSecondInfoItem.ItemId.Id; copyItemIdType2.ChangeKey = this.firstItemOfSecondInfoItem.ItemId.ChangeKey; #endregion #region Move the copied multiple message from junkemail to deleteditems MoveItemType moveItemRequest = new MoveItemType { // Set to copied message responseMessageItem id. ItemIds = new ItemIdType[] { copyItemIdType1, copyItemIdType2 }, // Move the copied messages to deleted items folder. ToFolderId = new TargetFolderIdType { Item = new DistinguishedFolderIdType { Id = DistinguishedFolderIdNameType.deleteditems } } }; MoveItemResponseType moveItemResponse = this.MSGAdapter.MoveItem(moveItemRequest); Site.Assert.IsTrue(this.VerifyMultipleResponse(moveItemResponse), @"Server should return success for moving the email messages."); this.infoItems = TestSuiteHelper.GetInfoItemsInResponse(moveItemResponse); this.firstItemOfFirstInfoItem = TestSuiteHelper.GetItemTypeItemFromInfoItemsByIndex(this.infoItems, 0, 0); Site.Assert.IsNotNull(this.infoItems, @"InfoItems in the returned response should not be null."); Site.Assert.IsNotNull(this.firstItemOfFirstInfoItem, @"The first item of the array of ItemType type returned from server response should not be null."); // Save the ItemId of the first message responseMessageItem got from the MoveItem response. Site.Assert.IsNotNull(this.firstItemOfFirstInfoItem.ItemId, @"The ItemId property of the first item should not be null."); copyItemIdType1.Id = this.firstItemOfFirstInfoItem.ItemId.Id; copyItemIdType1.ChangeKey = this.firstItemOfFirstInfoItem.ItemId.ChangeKey; // Save the ItemId of the second message responseMessageItem got from the MoveItem response. this.firstItemOfSecondInfoItem = TestSuiteHelper.GetItemTypeItemFromInfoItemsByIndex(this.infoItems, 1, 0); Site.Assert.IsNotNull(this.firstItemOfSecondInfoItem, @"The second item of the array of ItemType type returned from server response should not be null."); Site.Assert.IsNotNull(this.firstItemOfSecondInfoItem.ItemId, @"The ItemId property of the second item should not be null."); copyItemIdType2.Id = this.firstItemOfSecondInfoItem.ItemId.Id; copyItemIdType2.ChangeKey = this.firstItemOfSecondInfoItem.ItemId.ChangeKey; #endregion #region Send multiple messages SendItemType sendItemRequest = new SendItemType { // Set to the two updated messages' ItemIds. ItemIds = new ItemIdType[] { itemIdType1, itemIdType2 }, // Do not save copy. SaveItemToFolder = false, }; SendItemResponseType sendItemResponse = this.MSGAdapter.SendItem(sendItemRequest); Site.Assert.IsTrue(this.VerifyMultipleResponse(sendItemResponse), @"Server should return success for sending the email messages."); #endregion #region Delete the copied messages DeleteItemType deleteItemRequest = new DeleteItemType { // Set to the two copied messages' ItemIds. ItemIds = new ItemIdType[] { copyItemIdType1, copyItemIdType2 } }; DeleteItemResponseType deleteItemResponse = this.MSGAdapter.DeleteItem(deleteItemRequest); Site.Assert.IsTrue(this.VerifyMultipleResponse(deleteItemResponse), @"Server should return success for deleting the email messages."); #endregion #region Clean up Recipient1's and Recipient2's inbox folders bool isClear = this.MSGSUTControlAdapter.CleanupFolders( Common.GetConfigurationPropertyValue("Recipient2", this.Site), Common.GetConfigurationPropertyValue("Recipient2Password", this.Site), this.Domain, subject, "inbox"); Site.Assert.IsTrue(isClear, "Recipient2's inbox folder should be cleaned up."); isClear = this.MSGSUTControlAdapter.CleanupFolders( Common.GetConfigurationPropertyValue("Recipient1", this.Site), Common.GetConfigurationPropertyValue("Recipient1Password", this.Site), this.Domain, anotherSubject, "inbox"); Site.Assert.IsTrue(isClear, "Recipient1's inbox folder should be cleaned up."); #endregion }