Finding an Exchange Cross Folder Using Exchange Web Services

Is there a way to search Exchange using the EWS managed API for all email messages in all folders. I am using the FindItems API call, but it seems to require the search to be limited to one folder.

   private void InternalPurgeProcessFolder(FolderId folderId, ExchangeService service, SearchFilter searchCriteria) {

        Logger.Info("Processing folder {0}", folderId.FolderName);

        int pageSize = _runtimeParameters.ExchangeRetrievalPageSize;
        ItemView itemView = new ItemView(pageSize);
        itemView.PropertySet = Utils.BasicPropertySet();
        const int maxInterationsForTesting = 2;
        int iterations = 0;
        FindItemsResults<Item> findResults;
        do {
            ++iterations;
            Logger.Debug("Start of iteration {0}", iterations);
            findResults = service.FindItems(folderId, searchCriteria, itemView);
            _dumper.ListDatesAndSubjectsBrief(findResults);
            itemView.Offset += pageSize;
        } while ((findResults.MoreAvailable) && (iterations < maxInterationsForTesting));
    }
+3
source share
1 answer

To find items by folder, you can create a search folder and in SearchFolderParameters set RootFolderIds to the root folder of the mailbox and crawl mode on SearchFolderTraversal.Deep.

+3
source

Source: https://habr.com/ru/post/1756600/


All Articles