/// <summary>
        /// Loop to find the item with the specified subject.
        /// </summary>
        /// <param name="folderName">Name of the specified folder.</param>
        /// <param name="itemSubject">Subject of the specified item.</param>
        /// <param name="itemType">Type of the specified item.</param>
        /// <returns>Item with the specified subject.</returns>
        private ItemType LoopToFindItem(DistinguishedFolderIdNameType folderName, string itemSubject, Item itemType)
        {
            ItemType[] items = null;
            ItemType firstFoundItem = null;
            int sleepTimes = 0;

            // Get the query sleep delay and times from ptfconfig file.
            int queryDelay = int.Parse(Common.GetConfigurationPropertyValue("WaitTime", this.Site));
            int queryTimes = int.Parse(Common.GetConfigurationPropertyValue("RetryCount", this.Site));

            // Loop to find the item, in case that the sent item has still not been received.
            do
            {
                Thread.Sleep(queryDelay);
                items = this.FindAllItems(folderName);
                sleepTimes++;
            }
            while (items == null && sleepTimes < queryTimes);

            ItemType type = null;

            switch (itemType)
            {
                case Item.MeetingRequest:
                    type = new MeetingRequestMessageType();
                    break;
                case Item.MeetingResponse:
                    type = new MeetingResponseMessageType();
                    break;
                case Item.MeetingCancellation:
                    type = new MeetingCancellationMessageType();
                    break;
                case Item.CalendarItem:
                    type = new CalendarItemType();
                    break;
            }

            if (items != null)
            {
                // Find the item with the specified subject and store its ID.
                for (int i = 0; i < items.Length; i++)
                {
                    if (items[i].Subject.Contains(itemSubject) && items[i].GetType().ToString() == type.ToString())
                    {
                        firstFoundItem = items[i];
                        break;
                    }
                }
            }

            return firstFoundItem;
        }