Hantera konversationsobjekt på Exchange Server
Aspose.Email för .NET kan användas för att hantera konversationsobjekt på Exchange Server med EWSClient klass. Denna klass använder Exchange Web Services, som endast finns i Exchange Server 2007 och senare. Den här artikeln visar hur man hitta, kopiera, flytta och radera konversationsobjekt på Exchange Server 2010. Microsoft Exchange Server 2010 Service Pack 1 krävs för alla funktioner som ingår i detta avsnitt.
Hitta konversationer
För att hämta konversationsinformation från en specifik mapp på Exchange Server:
- Anslut till Exchange Server med hjälp av IEWSClient gränssnitt.
- Anropa IEWSClient.FindConversations() metod för att hitta alla konversationsobjekt från en mapp.
- Visa konversationsobjektets egenskaper som ID, samtalsämne och flaggstatus.
Följande kodsnutt visar hur du hittar konversationer.
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();
}
Kopiera konversationer
För att kopiera konversationer från en mapp till en annan:
- Anslut till Exchange Server med hjälp av IEWSClient gränssnitt.
- Anropa IEWSClient.CopyConversationItems() metod för att kopiera konversationsobjektet från källmappen till målmappen.
Följande kodsnutt visar hur du kopierar konversationer.
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");
}
}
Flytta konversationer
För att flytta konversationer från en mapp till en annan:
- Anslut till Exchange Server med hjälp av IEWSClient gränssnitt.
- Anropa IEWSClient.MoveConversationItems() metod för att flytta en konversation från källmappen till målmappen.
Följande kodsnutt visar hur du flyttar konversationer.
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");
}
}
Ta bort konversationer
För att radera konversationer från en mapp:
- Anslut till Exchange Server med hjälp av IEWSClient gränssnitt.
- Anropa IEWSClient.DeleteConversationItems() metod för att ta bort konversationsobjektet från källmappen.
Följande kodsnutt visar hur du raderar konversationer.
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");
}
}