Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Last active March 31, 2022 06:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aspose-com-gists/3cd2f5b427b5f7837a575250ce147fa9 to your computer and use it in GitHub Desktop.
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
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");
}
}
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");
}
}
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();
}
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