FindFolderAsync Method (FindFolderType)
Collapse the table of content
Expand the table of content
The document is archived and information here might be outdated

ExchangeServiceBinding.FindFolderAsync Method (FindFolderType)

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

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

public void FindFolderAsync(
	FindFolderType FindFolder1
)

Parameters

FindFolder1
Type: ExchangeWebServices.FindFolderType
The FindFolder request.

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;
}
Show:
© 2016 Microsoft