/// <summary> /// Log on a mailbox with a specified user account and check whether the specified item exists. /// </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 exist.</param> /// <param name="itemType">Type of the item which should exist.</param> /// <returns>If the item exists, return true; otherwise, return false.</returns> public bool IsItemExisting(string userName, string userPassword, string userDomain, string folderName, string itemSubject, string itemType) { bool isExisting = false; // Parse the parent folder name to DistinguishedFolderIdNameType. DistinguishedFolderIdNameType parentFolderIdName = (DistinguishedFolderIdNameType)Enum.Parse(typeof(DistinguishedFolderIdNameType), folderName, true); // 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)); Item item = (Item)Enum.Parse(typeof(Item), itemType, true); // Loop to find the specified item ItemType type = this.LoopToFindItem(parentFolderIdName, itemSubject, item); if (type != null) { switch (item) { case Item.MeetingRequest: MeetingRequestMessageType requestMessage = type as MeetingRequestMessageType; if (requestMessage != null) { isExisting = true; } break; case Item.MeetingResponse: MeetingResponseMessageType responseMessage = type as MeetingResponseMessageType; if (responseMessage != null) { isExisting = true; } break; case Item.MeetingCancellation: MeetingCancellationMessageType cancellationMessage = type as MeetingCancellationMessageType; if (cancellationMessage != null) { isExisting = true; } break; case Item.CalendarItem: CalendarItemType calendarItem = type as CalendarItemType; if (calendarItem != null) { isExisting = true; } break; } } return(isExisting); }