Manage Conversation Items on Exchange Server

Skip to end of metadata
Go to start of metadata
This page is no longer maintained. For an updated page, please visit Managing Conversation Items
Aspose.Email for .NET can be used to manage the conversation items on Exchange Server with the EWSClient class. This class uses Exchange Web Services, which are only available in Exchange Server 2007 and later releases.

This article shows how to find, copy, update and delete conversation items on Exchange Server 2010.

Microsoft Exchange Server 2010 Service Pack 1 is required for all the features included in this section.

Set Up

Below is the code uses to connect to Exchange Server 2010 in all the examples in this article.

Programming Samples

[C#]
private static IEWSClient GetAsposeEWSClient()
{
	const string mailboxUri = "https://exchange/ews/exchange.asmx";
	const string domain = @"";
	const string username = @"username@ASE305.onmicrosoft.com";
	const string password = @"password";
	NetworkCredential credentials = new NetworkCredential(username, password, domain);
	IEWSClient client = EWSClient.GetEWSClient(mailboxUri, credentials);
	return client;
}
[VB.NET]
Private Function GetAsposeEWSClient() As IEWSClient
	Const  mailboxUri As String = "https://exchange/ews/exchange.asmx"
	Const  domain As String = ""
	Const  username As String = "username@ASE305.onmicrosoft.com"
	Const  password As String = "password"
	Dim credentials As New NetworkCredential(username, password, domain)
	Dim client As IEWSClient = EWSClient.GetEWSClient(mailboxUri, credentials)
	Return client
End Function

Finding Conversations

To get the conversation information from a specific folder on the Exchange Server:# Connect to the Exchange Server using the [{{ExchangeWebServiceClient}}] class.# Call the ExchangeWebServiceClient.FindConversations() method to find all the conversation items from a folder.# Display the conversation item properties like ID, conversation topic and flag status.

Programming Samples

[C#]
ExchangeWebServiceClient client = GetAsposeEWSClient();
Console.WriteLine("Connected to Exchange 2010");

// Find Conversation Items in the Inbox folder
ExchangeConversation[] conversations = client.FindConversations(client.MailboxInfo.InboxUri);
// Show all conversations
foreach (ExchangeConversation conversation in conversations)
{
    // Display conversation properties like Id and Topic
    Console.WriteLine("Topic: " + conversation.ConversationTopic);
    Console.WriteLine("Flag Status: " + conversation.FlagStatus.ToString());
    Console.WriteLine();
}
 
[VB.NET]
Dim client As ExchangeWebServiceClient = GetAsposeEWSClient()
Console.WriteLine("Connected to Exchange 2010")

' Find Conversation Items in the Inbox folder
Dim conversations As ExchangeConversation() = client.FindConversations(client.MailboxInfo.InboxUri)
' Show all conversations
For Each conversation As ExchangeConversation In conversations
    ' Display conversation properties like Id and Topic
    Console.WriteLine("Topic: " & conversation.ConversationTopic)
    Console.WriteLine("Flag Status: " & conversation.FlagStatus.ToString())
    Console.WriteLine()
Next conversation
 

Copying Conversations

To copy conversations from one folder to another:# Connect to the Exchange Server using the [{{ExchangeWebServiceClient}}] class.# Call the ExchangeWebServiceClient.CopyConversationItems() method to copy the conversation item from source folder to destination folder.

Programming Samples

[C#]
ExchangeWebServiceClient client = GetAsposeEWSClient();
Console.WriteLine("Connected to Exchange 2010");

// Find those Conversation Items in the Inbox folder which we want to copy
ExchangeConversation[] conversations = client.FindConversations(client.MailboxInfo.InboxUri);

foreach (ExchangeConversation conversation in conversations)
{
    // Display topic
    Console.WriteLine("Topic: " + conversation.ConversationTopic);

    // Copy the conversation item based on some condition
    if (conversation.ConversationTopic.Contains("test email") == true)
    {
        client.CopyConversationItems(conversation.ConversationId, client.MailboxInfo.DeletedItemsUri);
        Console.WriteLine("Copied the conversation item to another folder");
    }
}
 
[VB.NET]
Dim client As ExchangeWebServiceClient = GetAsposeEWSClient()
Console.WriteLine("Connected to Exchange 2010")

' Find those Conversation Items in the Inbox folder which we want to copy
Dim conversations As ExchangeConversation() = client.FindConversations(client.MailboxInfo.InboxUri)

For Each conversation As ExchangeConversation In conversations
    ' Display topic
    Console.WriteLine("Topic: " & conversation.ConversationTopic)

    ' Copy the conversation item based on some condition
    If conversation.ConversationTopic.Contains("test email") = True Then
        client.CopyConversationItems(conversation.ConversationId, client.MailboxInfo.DeletedItemsUri)
        Console.WriteLine("Copied the conversation item to another folder")
    End If
Next conversation
 

Moving Conversations

To move conversations from one folder to another:

  1. Connect to the Exchange Server using the [{{ExchangeWebServiceClient}}] class.
  2. Call the ExchangeWebServiceClient.MoveConversationItems() method to move a conversation from the source folder to the destination folder.

Programming Samples

[C#]
ExchangeWebServiceClient client = GetAsposeEWSClient();
Console.WriteLine("Connected to Exchange 2010");

// Find those Conversation Items in the Inbox folder which we want to move
ExchangeConversation[] conversations = client.FindConversations(client.MailboxInfo.InboxUri);

foreach (ExchangeConversation conversation in conversations)
{
    // Display topic
    Console.WriteLine("Topic: " + conversation.ConversationTopic);

    // Move the conversation item based on some condition
    if (conversation.ConversationTopic.Contains("test email") == true)
    {
        client.MoveConversationItems(conversation.ConversationId, client.MailboxInfo.DeletedItemsUri);
        Console.WriteLine("Moved the conversation item to another folder");
    }
}
 
[VB.NET]
Dim client As ExchangeWebServiceClient = GetAsposeEWSClient()
Console.WriteLine("Connected to Exchange 2010")

' Find those Conversation Items in the Inbox folder which we want to move
Dim conversations As ExchangeConversation() = client.FindConversations(client.MailboxInfo.InboxUri)

For Each conversation As ExchangeConversation In conversations
    ' Display topic
    Console.WriteLine("Topic: " & conversation.ConversationTopic)

    ' Move the conversation item based on some condition
    If conversation.ConversationTopic.Contains("test email") = True Then
        client.MoveConversationItems(conversation.ConversationId, client.MailboxInfo.DeletedItemsUri)
        Console.WriteLine("Moved the conversation item to another folder")
    End If
Next conversation
 

Deleting Conversations

To delete conversations from a folder:

  1. Connect to the Exchange Server using the [{{ExchangeWebServiceClient}}] class.
  2. Call the ExchangeWebServiceClient.DeleteConversationItems() method to delete the conversation item from the source folder.

Programming Samples

[C#]
ExchangeWebServiceClient client = GetAsposeEWSClient();
Console.WriteLine("Connected to Exchange 2010");

// Find those Conversation Items in the Inbox folder which we want to delete
ExchangeConversation[] conversations = client.FindConversations(client.MailboxInfo.InboxUri);

foreach (ExchangeConversation conversation in conversations)
{
    // Display topic
    Console.WriteLine("Topic: " + conversation.ConversationTopic);

    // Delete the conversation item based on some condition
    if (conversation.ConversationTopic.Contains("test email") == true)
    {
        client.DeleteConversationItems(conversation.ConversationId);
        Console.WriteLine("Deleted the conversation item");
    }
}
 
[VB.NET]
Dim client As ExchangeWebServiceClient = GetAsposeEWSClient()
Console.WriteLine("Connected to Exchange 2010")

' Find those Conversation Items in the Inbox folder which we want to delete
Dim conversations As ExchangeConversation() = client.FindConversations(client.MailboxInfo.InboxUri)

For Each conversation As ExchangeConversation In conversations
    ' Display topic
    Console.WriteLine("Topic: " & conversation.ConversationTopic)

    ' Delete the conversation item based on some condition
    If conversation.ConversationTopic.Contains("test email") = True Then
        client.DeleteConversationItems(conversation.ConversationId)
        Console.WriteLine("Deleted the conversation item")
    End If
Next conversation
 
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.