Verwalten von Konversations‑Elementen auf einem Exchange‑Server
Aspose.Email für .NET kann verwendet werden, um die Konversations‑Elemente auf einem Exchange‑Server mit der EWSClient Klasse. Diese Klasse verwendet Exchange Web Services, die nur in Exchange Server 2007 und späteren Releases verfügbar sind. Dieser Artikel zeigt, wie man finden, kopieren, verschieben und löschen Konversations‑Elemente auf Exchange Server 2010. Microsoft Exchange Server 2010 Service Pack 1 ist für alle in diesem Abschnitt enthaltenen Funktionen erforderlich.
Konversationen finden
Um die Konversations‑Informationen aus einem bestimmten Ordner auf dem Exchange‑Server zu erhalten:
- Verbinden Sie sich mit dem Exchange‑Server über die IEWSClient Interface.
- Rufen Sie die IEWSClient.FindConversations() Methode, um alle Konversations‑Elemente aus einem Ordner zu finden.
- Zeigen Sie die Eigenschaften des Konversations‑Elements wie ID, Konversationsthema und Flag‑Status an.
Das folgende Code‑Snippet zeigt, wie Sie Konversationen finden.
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();
}
Konversationen kopieren
Um Konversationen von einem Ordner in einen anderen zu kopieren:
- Verbinden Sie sich mit dem Exchange‑Server über die IEWSClient Interface.
- Rufen Sie die IEWSClient.CopyConversationItems() Methode, um das Konversations‑Element vom Quellordner in den Zielordner zu kopieren.
Das folgende Code‑Snippet zeigt, wie Sie Konversationen kopieren.
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");
}
}
Konversationen verschieben
Um Konversationen von einem Ordner in einen anderen zu verschieben:
- Verbinden Sie sich mit dem Exchange‑Server über die IEWSClient Interface.
- Rufen Sie die IEWSClient.MoveConversationItems() Methode, um eine Konversation vom Quellordner in den Zielordner zu verschieben.
Das folgende Code‑Snippet zeigt, wie Sie Konversationen verschieben.
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");
}
}
Konversationen löschen
Um Konversationen aus einem Ordner zu löschen:
- Verbinden Sie sich mit dem Exchange‑Server über die IEWSClient Interface.
- Rufen Sie die IEWSClient.DeleteConversationItems() Methode, um das Konversations‑Element aus dem Quellordner zu löschen.
Das folgende Code‑Snippet zeigt, wie Sie Konversationen löschen.
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");
}
}