Read the complete article on how to find, copy, move, and delete conversations from Microsoft Exchange Server in C# .NET: https://blog.aspose.com/2022/03/31/work-with-conversations-in-ms-exchange-server-in-csharp/
Last active
March 31, 2022 06:40
-
-
Save aspose-com-gists/3cd2f5b427b5f7837a575250ce147fa9 to your computer and use it in GitHub Desktop.
Find, copy, move, and delete conversations from Microsoft Exchange Server in C# .NET
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string mailboxUri = "https://ex2010/ews/exchange.asmx"; | |
string username = "test.exchange"; | |
string password = "pwd"; | |
string domain = "ex2010.local"; | |
NetworkCredential credentials = new NetworkCredential(username, password, domain); | |
// Connect to MS Exchange Server | |
IEWSClient client = EWSClient.GetEWSClient(mailboxUri, credentials); | |
Console.WriteLine("Connected to Exchange"); | |
// Get conversations | |
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"); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string mailboxUri = "https://ex2010/ews/exchange.asmx"; | |
string username = "test.exchange"; | |
string password = "pwd"; | |
string domain = "ex2010.local"; | |
NetworkCredential credentials = new NetworkCredential(username, password, domain); | |
// Connect to MS Exchange Server | |
IEWSClient client = EWSClient.GetEWSClient(mailboxUri, credentials); | |
Console.WriteLine("Connected to Exchange"); | |
// Get conversations | |
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"); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string mailboxUri = "https://ex2010/ews/exchange.asmx"; | |
string username = "test.exchange"; | |
string password = "pwd"; | |
string domain = "ex2010.local"; | |
NetworkCredential credentials = new NetworkCredential(username, password, domain); | |
// Connect to MS Exchange Server | |
IEWSClient client = EWSClient.GetEWSClient(mailboxUri, credentials); | |
Console.WriteLine("Connected to Exchange"); | |
// Get conversations from inbox | |
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(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string mailboxUri = "https://ex2010/ews/exchange.asmx"; | |
string username = "test.exchange"; | |
string password = "pwd"; | |
string domain = "ex2010.local"; | |
NetworkCredential credentials = new NetworkCredential(username, password, domain); | |
// Connect to MS Exchange Server | |
IEWSClient client = EWSClient.GetEWSClient(mailboxUri, credentials); | |
Console.WriteLine("Connected to Exchange"); | |
// Get conversations | |
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"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment