翻譯|使用教程|編輯:胡濤|2022-04-01 16:00:19.590|閱讀 208 次
概述:
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關(guān)鏈接:
Microsoft Exchange Server上的對話稱為線程中的電子郵件消息組。簡而言之,一封電子郵件及其所有回復(fù)都被稱為對話。在本文中,我們將向您展示如何以編程方式在 MS Exchange Server 中處理對話。特別是,您將學(xué)習(xí)如何在 C# .NET 中查找、復(fù)制、移動和刪除 MS Exchange Server 上的對話。
為了管理 Microsoft Exchange Server 上的對話,我們將使用 Aspose.Email for .NET。它是一個強大的 API,提供了一系列功能來實現(xiàn)電子郵件客戶端應(yīng)用程序。此外,它還允許您無縫訪問 MS Exchange Server 的各種服務(wù)。您可以 下載 API 的 DLL 或 使用以下命令從NuGet安裝它。
PM> Install-Package Aspose.Email
以下是在 C# 中從 MS Exchange Server 中的文件夾中查找對話的步驟。
以下代碼示例顯示了如何在 C# 中從 MS Exchange Server 中的文件夾中查找對話。
string mailboxUri = "http://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(); }
您還可以將對話從一個文件夾復(fù)制到另一個文件夾,而無需編寫復(fù)雜的代碼。為了演示,讓我們看看如何在 C# .NET 中將對話從收件箱復(fù)制到 Exchange Server 的已刪除項目文件夾。
以下代碼示例顯示如何使用 C# .NET 在 MS Exchange Server 中復(fù)制對話。
string mailboxUri = "http://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"); } }
在上一節(jié)中,我們只是將對話從一個文件夾復(fù)制到另一個文件夾。但是,在某些情況下,您可能需要將對話移至特定文件夾。以下是在 C# .NET 中在 MS Exchange Server 中移動對話的步驟。
以下代碼示例顯示了如何使用 C# .NET 在 MS Exchange Server 中移動對話。
string mailboxUri = "http://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"); } }
最后但并非最不重要的一點,讓我們看看如何在 C# 中從 MS Exchange Server 中刪除對話。
以下代碼示例顯示了如何在 C# .NET 中從 MS Exchange Server 中刪除對話。
string mailboxUri = "http://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"); } }
在本文中,您學(xué)習(xí)了如何使用 C# 在 Microsoft Exchange Server 中管理對話。您已經(jīng)了解了如何在 C# 中以編程方式在 MS Exchange Server 上查找、復(fù)制、移動和刪除對話。此外,您可以瀏覽 文檔 以閱讀有關(guān) Aspose.Email for .NET 的更多信息。此外,你還可以將您的需求告知我們!
歡迎下載|體驗更多Aspose產(chǎn)品
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請郵件反饋至chenjj@fc6vip.cn