How to: Find conversations by using the EWS Managed API 2.0

EWS Managed API

Last modified: February 07, 2014

Applies to: EWS Managed API | Exchange Server 2010 Service Pack 1 (SP1)

Note: This content applies to the EWS Managed API 2.0 and earlier versions. For the latest information about the EWS Managed API, see Web services in Exchange.

You can use the Exchange Web Services (EWS) Managed API to find conversations in a mailbox.

Note Note

The conversation feature is available in versions of Exchange starting with Exchange Server 2010 Service Pack 1 (SP1).

The following example shows how to find the first five conversations in the Inbox folder and then write the conversation topic, last delivery time, and global unique recipient list to the console window.

Sub FindConversation(ByVal service As ExchangeService)

  ' Create the view of conversations returned in the response. This view will return the first five
  ' conversations starting with an offset of 0 from the beginning of the results set.
  Dim view As New ConversationIndexedItemView(5, 0, OffsetBasePoint.Beginning)

  ' Search the inbox for conversations and return a results set with the specified view.
  ' This results in a call to EWS. 
  Dim conversations As ICollection(Of Conversation) = service.FindConversation(view, WellKnownFolderName.Inbox)

  Dim conversation As Conversation

  ' Examine properties on each conversation returned in the response.
  For Each conversation In conversations
     Console.WriteLine(("Conversation Topic: " & conversation.Topic))
     Console.WriteLine(("Last Delivered: " & conversation.LastDeliveryTime.ToString))
     Dim GlUniqRec As String
     For Each GlUniqRec In conversation.GlobalUniqueRecipients
        Console.WriteLine(("Global Unique Recipient: " & GlUniqRec))
End Sub

For information about compiling this code, see Getting started with the EWS Managed API 2.0.

  • Write appropriate error handling code for common search errors.

  • Review the client request XML that is sent to the Exchange server.

  • Review the server response XML that is sent from the Exchange server.

  • Set the service binding as shown in Setting the Exchange service URL by using the EWS Managed API 2.0. Do not hard code URLs because if mailboxes move, they might be serviced by a different Client Access server. If the client cannot connect to the service, retry setting the binding by using the AutodiscoverUrl(String) method.

  • Set the target Exchange Web Services schema version by setting the requestedServerVersion parameter of the ExchangeService constructor. For more information, see Versioning EWS requests by using the EWS Managed API 2.0.

  • Use HTTP with SSL for all communication between client and server.

  • Always validate the server certificate that is used for establishing the SSL connections. For more information, see Validating X509 certificates by using the EWS Managed API 2.0.

  • Do not include user names and passwords in trace files.

  • Verify that Autodiscover lookups that use HTTP GET to find an endpoint always prompt for user confirmation; otherwise, they should be blocked.