Пример #1
0
 /// <remarks/>
 public void FindItemAsync(FindItemType FindItem1, object userState) {
     if ((this.FindItemOperationCompleted == null)) {
         this.FindItemOperationCompleted = new System.Threading.SendOrPostCallback(this.OnFindItemOperationCompleted);
     }
     this.InvokeAsync("FindItem", new object[] {
                 FindItem1}, this.FindItemOperationCompleted, userState);
 }
Пример #2
0
        /********************************************************************
          * GET UNREAD FOLDER ITEMS
          ********************************************************************/
        private static List<ItemType> GetUnReadFolderItems(String folderName)
        {

            FindItemType findRequest = new FindItemType();
            findRequest.ItemShape = new ItemResponseShapeType();

            ItemResponseShapeType itemProperties = new ItemResponseShapeType();
            // Use the Default shape for the response.            
            itemProperties.BaseShape = DefaultShapeNamesType.AllProperties;
            itemProperties.BodyType = BodyTypeResponseType.Text;
            itemProperties.BodyTypeSpecified = true;

            RestrictionType restrict = new RestrictionType();
            IsEqualToType isEqTo = new IsEqualToType();
            PathToUnindexedFieldType ptuift = new PathToUnindexedFieldType();
            ptuift.FieldURI = UnindexedFieldURIType.messageIsRead;
            isEqTo.Item = ptuift;
            FieldURIOrConstantType msgReadYes = new FieldURIOrConstantType();
            msgReadYes.Item = new ConstantValueType();
            (msgReadYes.Item as ConstantValueType).Value = "0";  //1= boolean yes; so you'll get the list of read messages
            isEqTo.FieldURIOrConstant = msgReadYes;
            restrict.Item = isEqTo;
            findRequest.Restriction = restrict;

            findRequest.ItemShape = itemProperties;

            //Set the inbox as the parent search folder in search attachementRequest.
            BaseFolderIdType p_folder = FindFolderID(folderName);
            findRequest.ParentFolderIds = new BaseFolderIdType[] { p_folder };
            findRequest.Traversal = ItemQueryTraversalType.Shallow;


            // Perform the inbox search
            FindItemResponseType response = service.FindItem(findRequest);
            FindItemResponseMessageType responseMessage = response.ResponseMessages.Items[0] as FindItemResponseMessageType;
            if (responseMessage.ResponseCode != ResponseCodeType.NoError)
            {
                throw new Exception(responseMessage.MessageText);
            }
            else
            {

                // find items details
                GetItemResponseType response2 = service.GetItem(new GetItemType
                {
                    ItemIds = ((response as FindItemResponseType)
                                .ResponseMessages
                                .Items
                                .Select(n => n as FindItemResponseMessageType)
                                .Select(n => n.RootFolder).Single().Item as ArrayOfRealItemsType)
                                .Items
                                .Select(n => new ItemIdType { Id = n.ItemId.Id })
                                .ToArray()
                    ,
                    ItemShape = new ItemResponseShapeType
                    {
                        BaseShape = DefaultShapeNamesType.Default,
                        BodyType = BodyTypeResponseType.Text
                    }
                });

                List<ItemType> messages = new List<ItemType>();

                for (int j = 0; j < response2.ResponseMessages.Items.Count(); j++)
                    messages.Add(((ItemInfoResponseMessageType)response2.ResponseMessages.Items[j]).Items.Items[0]);


                return messages;
            }
        }
Пример #3
0
 /// <remarks/>
 public void FindItemAsync(FindItemType FindItem1) {
     this.FindItemAsync(FindItem1, null);
 }