Compartir a través de


GetFolderType Class

The GetFolderType class represents a request to get folders from a mailbox.

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

Syntax

'Declaration
<SerializableAttribute> _
<GeneratedCodeAttribute("wsdl", "2.0.50727.42")> _
<DesignerCategoryAttribute("code")> _
<XmlTypeAttribute(Namespace:="https://schemas.microsoft.com/exchange/services/2006/messages")> _
<DebuggerStepThroughAttribute> _
Public Class GetFolderType
    Inherits BaseRequestType
[SerializableAttribute] 
[GeneratedCodeAttribute("wsdl", "2.0.50727.42")] 
[DesignerCategoryAttribute("code")] 
[XmlTypeAttribute(Namespace="https://schemas.microsoft.com/exchange/services/2006/messages")] 
[DebuggerStepThroughAttribute] 
public class GetFolderType : BaseRequestType
[SerializableAttribute] 
[GeneratedCodeAttribute(L"wsdl", L"2.0.50727.42")] 
[DesignerCategoryAttribute(L"code")] 
[XmlTypeAttribute(Namespace=L"https://schemas.microsoft.com/exchange/services/2006/messages")] 
[DebuggerStepThroughAttribute] 
public ref class GetFolderType : public BaseRequestType
/** @attribute SerializableAttribute() */ 
/** @attribute GeneratedCodeAttribute("wsdl", "2.0.50727.42") */ 
/** @attribute DesignerCategoryAttribute("code") */ 
/** @attribute XmlTypeAttribute(Namespace="https://schemas.microsoft.com/exchange/services/2006/messages") */ 
/** @attribute DebuggerStepThroughAttribute() */ 
public class GetFolderType extends BaseRequestType
SerializableAttribute 
GeneratedCodeAttribute("wsdl", "2.0.50727.42") 
DesignerCategoryAttribute("code") 
XmlTypeAttribute(Namespace="https://schemas.microsoft.com/exchange/services/2006/messages") 
DebuggerStepThroughAttribute 
public class GetFolderType extends BaseRequestType

Remarks

The GetFolder operation is used to get regular, managed, and default folders from an Exchange mailbox.

Inheritance Hierarchy

System.Object
   ExchangeWebServices.BaseRequestType
    ExchangeWebServices.GetFolderType

Example

The following example shows you how to get two folders. One of the folders is identified by the FolderId property and the other folder is identified by the DistinguishedFolderId property. The response will contain the properties that are defined for the AllProperties response shape and the additional information that is provided by the ManagedFolderInformation property if it applies to the folder.

static void GetFolder(ExchangeServiceBinding esb)
{ 
    // Identify the folders to get.
    FolderIdType folder1 = new FolderIdType();
    DistinguishedFolderIdType sentitems = new DistinguishedFolderIdType();
    folder1.Id = "AQAlAE1BQG";
    sentitems.Id = DistinguishedFolderIdNameType.sentitems;

    // Identify the folder properties to return.
    FolderResponseShapeType properties = new FolderResponseShapeType();
    PathToUnindexedFieldType ptuft = new PathToUnindexedFieldType();
    ptuft.FieldURI = UnindexedFieldURIType.folderManagedFolderInformation;
    PathToUnindexedFieldType[] ptufts = new PathToUnindexedFieldType[1] { ptuft };
    properties.AdditionalProperties = ptufts; 
    properties.BaseShape = DefaultShapeNamesType.AllProperties;

    // Form the get folder request.
    GetFolderType request = new GetFolderType();
    request.FolderIds = new BaseFolderIdType[2] { folder1, sentitems };
    request.FolderShape = properties;

    try
    {
        // Send the request and get the response.
        GetFolderResponseType response = esb.GetFolder(request);
        ArrayOfResponseMessagesType aormt = response.ResponseMessages;
        ResponseMessageType[] rmta = aormt.Items;

        foreach (ResponseMessageType rmt in rmta)
        {
            if (rmt.ResponseClass == ResponseClassType.Success)
            {
                FolderInfoResponseMessageType firmt;
                firmt = (rmt as FolderInfoResponseMessageType);
                BaseFolderType[] folders = firmt.Folders;

                foreach (BaseFolderType folder in folders)
                {
                    if (folder is CalendarFolderType)
                    {
                        CalendarFolderType calendar;
                        calendar = (folder as CalendarFolderType);
                    }
                    else if (folder is ContactsFolderType)
                    {
                        // Handle the contacts folder.
                    }
                    else
                    { 
                        // Handle SearchFolderType, TasksFolderType,
                        // and FolderType.
                    }
                }
            }
        }
    }
    catch (Exception e)
    {
        Console.WriteLine(e.Message);
    }
}

Thread Safety

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

Platforms

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)