Share via


Retrieving Information from an Exchange Server (Windows CE 5.0)

Send Feedback

To retrieve information from an Exchange server, you do the following:

  • Set up a connection to a server
  • Use the connection to initiate search requests
  • Wait for the requests to complete
  • Retrieve the requested information

The specific steps for data retrieval are as follows:

  1. Using the information in the Obtaining a Pointer section of the IExchangeClient topic, create an instance of an object that implements the IExchangeClient interface.

  2. Call IExchangeClient::Initialize, passing a reference to an object you create that implements the IExchangeClientRequestCallback interface.

    The Exchange client library calls the methods in the IExchangeClientRequestCallback instance that you provide to communicate request-processing status to the application using the library. This information includes the following:

    • The results of a request
    • When a request completes processing
    • Ongoing status updates as a request is processed
  3. Provide the URL of the Exchange server to be used by calling IExchangeClient::SetServer.

  4. (Conditional) Provide the credentials necessary to log on to the Exchange server by calling IExchangeClient::SetCredentials.

    This step is not necessary if another application used the Windows CE Credential Manager to provide default domain and plaintext credentials.

    For more information about how the Exchange Client library uses credentials, see IExchangeClient::SetCredentials.

    For more information about security and the Exchange Client library, see Exchange Client Security.

  5. Initiate a search by calling an IExchangeClient request method; then save the returned IExchangeClientRequest instance.

    The IExchangeClient request methods are IExchangeClient::RequestContacts, IExchangeClient::RequestGALSearch, and IExchangeClient::RequestFreeBusyData.

    These methods return immediately; the requests are processed asynchronously.

  6. As the request initiated in the previous step is processed, the Exchange client library calls the IExchangeClientRequestCallback::OnRequestProgress method on the instance of IExchangeClientRequestCallback you provided in step 2.

    Your code can match the IExchangeClientRequest reference passed in OnRequestProgress to the references returned by the request initiation methods to identify which request the callback refers to, and to see how that request is being processed.

    (If your code only submits a single request at a time, your code can assume that any callback refers to that request.)

  7. When your OnRequestProgress implementation is called with an e_ecrsSucceeded value, your request has completed processing and the information returned by the request can be retrieved.

  8. Retrieve the returned information by calling IExchangeClientRequest::GetDataItemArray using the IExchangeClientRequest instance you obtained in step five.

    This gives you an instance of the IExchangeClientDataItemArray interface.

  9. Iterate through the data provided by the IExchangeClientDataItemArray instance you received in the previous step.

    The IExchangeClientDataItemArray::GetItemCount method returns the number of pieces of data generated by the request.

    To retrieve each piece of data, call IExchangeClientDataItemArray::GetItemAt and use the value of the second parameter, an out parameter of type IUnknown.

  10. Call IUnknown::QueryInterface on the IUnknown instance to obtain a reference to the appropriate data interface, depending on the type of request you made.

    For example, if you initiated the request using RequestContacts, call QueryInterface, looking for an IExchangeClientContactInformation interface.

    The other two data interfaces are IExchangeClientGALSearchInformation and IExchangeClientFreeBusyInformation.

  11. Use the methods of the data interface to obtain the data you originally initiated the request for.

    For example, if you initiated the request by calling RequestContacts, call IExchangeClientContactInformation::GetHomePhoneNumber to retrieve the home phone number of a particular contact.

See Also

Exchange Client Application Development

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.