Managing Conversation Items on Exchange Server
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, move 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.
Find Conversations
To get the conversation information from a specific folder on the Exchange Server:
- Connect to the Exchange Server using the IEWSClient interface.
- Call the IEWSClient.FindConversations() method to find all the conversation items from a folder.
- Display the conversation item properties like ID, conversation topic and flag status.
The following code snippet shows you how to find conversations.
// For complete examples and data files, please go to https://github.com/aspose-email/Aspose.Email-for-.NET | |
IEWSClient client = EWSClient.GetEWSClient(mailboxUri, credentials); | |
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(); | |
} |
Copy Conversations
To copy conversations from one folder to another:
- Connect to the Exchange Server using the IEWSClient interface.
- Call the IEWSClient.CopyConversationItems() method to copy the conversation item from source folder to destination folder.
The following code snippet shows you how to copying conversations.
// For complete examples and data files, please go to https://github.com/aspose-email/Aspose.Email-for-.NET | |
IEWSClient client = EWSClient.GetEWSClient(mailboxUri, credentials); | |
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) | |
{ | |
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"); | |
} | |
} |
Move Conversations
To move conversations from one folder to another:
- Connect to the Exchange Server using the IEWSClient interface.
- Call the IEWSClient.MoveConversationItems() method to move a conversation from the source folder to the destination folder.
The following code snippet shows you how to moving conversations.
// For complete examples and data files, please go to https://github.com/aspose-email/Aspose.Email-for-.NET | |
IEWSClient client = EWSClient.GetEWSClient(mailboxUri, credentials); | |
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) | |
{ | |
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"); | |
} | |
} |
Delete Conversations
To delete conversations from a folder:
- Connect to the Exchange Server using the IEWSClient interface.
- Call the IEWSClient.DeleteConversationItems() method to delete the conversation item from the source folder.
The following code snippet shows you how to delete conversations.
// For complete examples and data files, please go to https://github.com/aspose-email/Aspose.Email-for-.NET | |
IEWSClient client = EWSClient.GetEWSClient(mailboxUri, credentials); | |
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) | |
{ | |
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"); | |
} | |
} |