Compartir a través de


ExchangeServiceBinding.FindFolderAsync Method (FindFolderType)

The FindFolderAsync method provides asynchronous access to the FindFolder Web service method.

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

Syntax

'Declaration
Public Sub FindFolderAsync ( _
    FindFolder1 As FindFolderType _
)
'Usage
Dim instance As ExchangeServiceBinding
Dim FindFolder1 As FindFolderType

instance.FindFolderAsync(FindFolder1)
public void FindFolderAsync(
    FindFolderType FindFolder1
)

Parameters

Examples

The following example shows how to perform an asynchronous FindFolder call.

static void FindFolderA(ExchangeServiceBinding esb)
{ 
    // Register the event.
    esb.FindFolderCompleted += new FindFolderCompletedEventHandler(HandleFindFolderCompleted);

    // Create the request.
    FindFolderType request = new FindFolderType();
    request.FolderShape = new FolderResponseShapeType();
    request.FolderShape.BaseShape = DefaultShapeNamesType.AllProperties;
    request.Traversal = FolderQueryTraversalType.Deep;
    request.ParentFolderIds = new BaseFolderIdType[1];
    DistinguishedFolderIdType root = new DistinguishedFolderIdType();
    root.Id = DistinguishedFolderIdNameType.root;
    request.ParentFolderIds[0] = root;

    // Send the asynchronous request.
    esb.FindFolderAsync(request);

    // Wait for the response.
    while (!handled)
    {
        Thread.Sleep(1000);
        Console.Write("Waiting\r\n");
    }
}

static private bool handled = false;

static void HandleFindFolderCompleted(object sender, FindFolderCompletedEventArgs e)
{
    if ((!e.Cancelled) && (e.Error == null))
    {
        FindFolderResponseType response = e.Result;
        // TODO: Handle the response.
    }
    handled = true;
}