FindFolderType 类

定义

FindFolderType 表示在邮箱中查找文件夹的请求。

public ref class FindFolderType : ExchangeWebServices::BaseRequestType
public class FindFolderType : ExchangeWebServices.BaseRequestType
Public Class FindFolderType
Inherits BaseRequestType
继承
FindFolderType

示例

以下示例显示了返回以下结果的 FindFolder 查询:

  1. 收件箱的深度遍历搜索。
  2. 在 FindFolder作中为 Default FolderShape 定义的所有属性。
  3. 显示名称为 SentOnlyToMe 的所有文件夹。 大小写不必匹配。
  4. 一种小数分页方案,最多返回一个文件夹,该文件夹在第一个文件夹之后开始。
static void FindFolder(ExchangeServiceBinding esb)
{
    // Create the request and specify the traversal type.
    FindFolderType <span class="label">findFolderRequest</span> = new FindFolderType();
<span class="label">findFolderRequest</span>.Traversal = FolderQueryTraversalType.Deep;

    // Define the properties to be returned in the response.
    FolderResponseShapeType responseShape = new FolderResponseShapeType();
    responseShape.BaseShape = DefaultShapeNamesType.Default;
<span class="label">findFolderRequest</span>.FolderShape = responseShape;

    // Identify which folders to search.
    DistinguishedFolderIdType[] folderIDArray = new DistinguishedFolderIdType[1];
    folderIDArray[0] = new DistinguishedFolderIdType();
    folderIDArray[0].Id = DistinguishedFolderIdNameType.inbox;

    // Add the folders to search to the request.
<span class="label">findFolderRequest</span>.ParentFolderIds = folderIDArray;

    // Restriction based on the folder display name.
    RestrictionType restriction = new RestrictionType();
    PathToUnindexedFieldType fldrRestriction = new PathToUnindexedFieldType();
    fldrRestriction.FieldURI = UnindexedFieldURIType.folderDisplayName;
    // Identify the folder name to restrict on.
    ContainsExpressionType contains = new ContainsExpressionType();
    contains.ContainmentMode = ContainmentModeType.Substring;
    contains.ContainmentModeSpecified = true;
    contains.ContainmentComparison = ContainmentComparisonType.IgnoreCase;
    contains.ContainmentComparisonSpecified = true;
    contains.Item = fldrRestriction;
    contains.Constant = new ConstantValueType();
    contains.Constant.Value = "SentOnlyToMe";
    restriction.Item = contains;
<span class="label">findFolderRequest</span>.Restriction = restriction;

    // Define the paging scheme for the result set.
    FractionalPageViewType fpvt = new FractionalPageViewType();
    fpvt.MaxEntriesReturned = 1;
    fpvt.MaxEntriesReturnedSpecified = true;
    fpvt.Numerator = 1;
    fpvt.Denominator = 4;
<span class="label">findFolderRequest</span>.Item = fpvt;

    try
    {
        // Send the request and get the response.
        FindFolderResponseType findFolderResponse = esb.FindFolder(<span class="label">findFolderRequest</span>);

        // Get the response messages.
        ResponseMessageType[] rmta = findFolderResponse.ResponseMessages.Items;

        foreach (ResponseMessageType rmt in rmta)
        {
            FindFolderResponseMessageType ffrmt = (rmt as FindFolderResponseMessageType);

            FindFolderParentType ffpt = ffrmt.RootFolder;
            BaseFolderType[] folders = ffpt.Folders;

            foreach (BaseFolderType folder in folders)
            {
                // Check folder type
                if (folder is CalendarFolderType)
                {
                    CalendarFolderType fldr = (folder as CalendarFolderType);
                    // TODO: Handle calendar folder
                }
                else 
                { 
                    // TODO: Handle folders, search folders, tasks folders,
                    // and contacts folder
                }
            }
        }
    }
    catch (Exception e)
    {
        Console.WriteLine(e.Message);
    }
}

注解

FindFolder作查找已标识文件夹的子文件夹。 FindFolder作仅返回任何可流属性的前 512 个字节。 对于 Unicode,FindFolder作使用以 null 结尾的 Unicode 字符串返回前 255 个字符。 使用 GetFolder作获取其他文件夹属性。

允许对文件夹属性(但不对项目属性)进行限制。 排序功能不适用于 FindFolder 响应。 分组查询不适用于 FindFolder 查询。

构造函数

FindFolderType()

构造 FindFolderType 函数初始化 类的新实例 FindFolderType

属性

FolderShape

属性 FolderShape 获取或设置查询集的形状。 此属性是必需项。 这是一个读/写属性。

Item

属性 Item 获取或设置分页类型,该类型描述如何在响应中对查询结果集进行分页。 此属性获取或设置 IndexedPageViewTypeFractionalPageViewType 对象。 此属性可选。 这是一个读/写属性。

ParentFolderIds

属性 ParentFolderIds 获取或设置 FindFolder作搜索的文件夹。 此属性是必需项。 这是一个读/写属性。

Restriction

属性 Restriction 获取或设置定义文件夹查询的搜索参数。 此属性可选。 这是一个读/写属性。

Traversal

属性 Traversal 获取或设置用于搜索文件夹的遍历方案。 此属性是必需项。 这是一个读/写属性。

适用于