Zarządzanie elementami konwersacji na Exchange Server
Aspose.Email dla .NET może być używany do zarządzania elementami konwersacji na Exchange Server przy użyciu EWSClient klasa. Ta klasa korzysta z Exchange Web Services, które są dostępne tylko w Exchange Server 2007 i późniejszych wersjach. Ten artykuł pokazuje, jak znajdź, kopiuj, przenieś i usuń elementy konwersacji na Exchange Server 2010. Microsoft Exchange Server 2010 Service Pack 1 jest wymagany dla wszystkich funkcji zawartych w tej sekcji.
Znajdź konwersacje
Aby uzyskać informacje o konwersacji z konkretnego folderu na serwerze Exchange:
- Połącz się z serwerem Exchange używając IEWSClient interfejsu.
- Wywołaj IEWSClient.FindConversations() metoda znajdująca wszystkie elementy konwersacji w folderze.
- Wyświetl właściwości elementu konwersacji, takie jak ID, temat konwersacji i status flagi.
Poniższy fragment kodu pokazuje, jak znaleźć konwersacje.
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();
}
Kopiuj konwersacje
Aby skopiować konwersacje z jednego folderu do drugiego:
- Połącz się z serwerem Exchange używając IEWSClient interfejsu.
- Wywołaj IEWSClient.CopyConversationItems() metoda kopiująca element konwersacji z folderu źródłowego do docelowego.
Poniższy fragment kodu pokazuje, jak kopiować konwersacje.
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");
}
}
Przenieś konwersacje
Aby przenieść konwersacje z jednego folderu do drugiego:
- Połącz się z serwerem Exchange używając IEWSClient interfejsu.
- Wywołaj IEWSClient.MoveConversationItems() metoda przenosząca konwersację ze źródłowego folderu do folderu docelowego.
Poniższy fragment kodu pokazuje, jak przenosić konwersacje.
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");
}
}
Usuń konwersacje
Aby usunąć konwersacje z folderu:
- Połącz się z serwerem Exchange używając IEWSClient interfejsu.
- Wywołaj IEWSClient.DeleteConversationItems() metoda usuwająca element konwersacji ze źródłowego folderu.
Poniższy fragment kodu pokazuje, jak usunąć konwersacje.
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");
}
}