Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

FindFolderType Class

The FindFolderType class represents a request to find folders in a mailbox.

Namespace: ExchangeWebServices
Assembly: EWS (in ews.dll)

[SerializableAttribute] 
[XmlTypeAttribute(Namespace="http://schemas.microsoft.com/exchange/services/2006/messages")] 
[GeneratedCodeAttribute("wsdl", "2.0.50727.42")] 
[DebuggerStepThroughAttribute] 
[DesignerCategoryAttribute("code")] 
public class FindFolderType : BaseRequestType
/** @attribute SerializableAttribute() */ 
/** @attribute XmlTypeAttribute(Namespace="http://schemas.microsoft.com/exchange/services/2006/messages") */ 
/** @attribute GeneratedCodeAttribute("wsdl", "2.0.50727.42") */ 
/** @attribute DebuggerStepThroughAttribute() */ 
/** @attribute DesignerCategoryAttribute("code") */ 
public class FindFolderType extends BaseRequestType
SerializableAttribute 
XmlTypeAttribute(Namespace="http://schemas.microsoft.com/exchange/services/2006/messages") 
GeneratedCodeAttribute("wsdl", "2.0.50727.42") 
DebuggerStepThroughAttribute 
DesignerCategoryAttribute("code") 
public class FindFolderType extends BaseRequestType

The FindFolder operation finds subfolders of an identified folder. The FindFolder operation returns only the first 512 bytes of any streamable property. For Unicode, the FindFolder operation returns the first 255 characters by using a null-terminated Unicode string. Use the GetFolder operation to get additional folder properties.

Restrictions on folder properties, but not item properties, are permitted. Sorting functionality is not available for FindFolder responses. Grouped queries are not available for FindFolder queries.


System.Object
   ExchangeWebServices.BaseRequestType
    ExchangeWebServices.FindFolderType

The following example shows a FindFolder query that returns the following results:

  1. A deep traversal search of the Inbox.

  2. All the properties that are defined for the Default FolderShape in a FindFolder operation.

  3. All folders that have a display name of SentOnlyToMe. The case does not have to match.

  4. A fractional paging scheme that returns at most a single folder that starts after the first folder.

static void FindFolder(ExchangeServiceBinding esb)
{
    // Create the request and specify the traversal type.
    FindFolderType findFolderRequest = new FindFolderType();
    findFolderRequest.Traversal = FolderQueryTraversalType.Deep;

    // Define the properties to be returned in the response.
    FolderResponseShapeType responseShape = new FolderResponseShapeType();
    responseShape.BaseShape = DefaultShapeNamesType.Default;
    findFolderRequest.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.
    findFolderRequest.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;
    findFolderRequest.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;
    findFolderRequest.Item = fpvt;

    try
    {
        // Send the request and get the response.
        FindFolderResponseType findFolderResponse = esb.FindFolder(findFolderRequest);

        // 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);
    }
}

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Development Platforms

Windows XP Professional with Service Pack 2 (SP2), Windows Server 2003,

Target Platforms

Windows 98, Windows 2000, Windows 2000 Server, Windows CE, Windows Longhorn, Windows 98 Second Edition, Pocket PC, Smart Phone, Windows Server 2003, Windows XP Professional with Service Pack 2 (SP2)
Show:
© 2015 Microsoft