FindItemsWithFolderIdAndQueryAndHighlightAndView method

Future<FindItemsResults<Item>?> FindItemsWithFolderIdAndQueryAndHighlightAndView(
  1. FolderId parentFolderId,
  2. String queryString,
  3. bool returnHighlightTerms,
  4. ViewBase view,
)
Obtains a list of items by searching the contents of a specific folder. Along with conversations, a list of highlight terms are returned. Calling this method results in a call to EWS. The Id of the folder in which to search for items. the search string to be used for indexed search, if any. Flag indicating if highlight terms should be returned in the response The view controlling the number of items returned.

Implementation

Future<FindItemsResults<Item>?>
    FindItemsWithFolderIdAndQueryAndHighlightAndView(FolderId parentFolderId,
        String queryString, bool returnHighlightTerms, ViewBase view) async {
  List<FolderId> parentFolderIds = [parentFolderId];

  EwsUtilities.ValidateParamCollection(parentFolderIds, "parentFolderIds");
  EwsUtilities.ValidateParam(view, "view");
  EwsUtilities.ValidateParamAllowNull(queryString, "queryString");
  EwsUtilities.ValidateParamAllowNull(
      returnHighlightTerms, "returnHighlightTerms");
  EwsUtilities.ValidateMethodVersion(
      this, ExchangeVersion.Exchange2013, "FindItems");

  FindItemRequest<Item> request =
      new FindItemRequest<Item>(this, ServiceErrorHandling.ThrowOnError);

  request.ParentFolderIds.AddRangeFolderIds(parentFolderIds);
  request.QueryString = queryString;
  request.ReturnHighlightTerms = returnHighlightTerms;
  request.View = view;

  ServiceResponseCollection<FindItemResponse<Item>> responses =
      await request.Execute();
  return responses[0].Results;
}