public static void Run()
{
const string mailboxUri = "https://exchange/ews/exchange.asmx";
const string domain = @"";
const string username = @"[email protected]";
const string password = @"password";
NetworkCredential credentials = new NetworkCredential(username, password, domain);
IEWSClient client = EWSClient.GetEWSClient(mailboxUri, credentials);
Console.WriteLine("Connected to Exchange 2010");
// ExStart:DeleteConversations
// 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");
}
}
// ExEnd:DeleteConversations
}
}