GetFolderType Class

Definition

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

public ref class GetFolderType : ExchangeWebServices::BaseRequestType
public class GetFolderType : ExchangeWebServices.BaseRequestType
Public Class GetFolderType
Inherits BaseRequestType
Inheritance
GetFolderType

Examples

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 <span class="label">request</span> = new GetFolderType();
<span class="label">request</span>.FolderIds = new BaseFolderIdType[2] { folder1, sentitems };
<span class="label">request</span>.FolderShape = properties;

    try
    {
        // Send the request and get the response.
        GetFolderResponseType response = esb.GetFolder(<span class="label">request</span>);
        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);
    }
}

Remarks

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

Constructors

GetFolderType()

The GetFolderType constructor initializes a new instance of the GetFolderType class.

Properties

FolderIds

The FolderIds property gets or sets the identifiers of the folders to get.

FolderShape

The FolderShape property gets or sets the properties to be returned in the response.

Applies to