翻譯|使用教程|編輯:胡濤|2022-04-18 11:46:22.773|閱讀 297 次
概述:在本文中,我們將介紹如何使用 C# 以編程方式在 MS Exchange Server 上添加、更新或刪除任務(wù)。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關(guān)鏈接:
不同的人創(chuàng)建要執(zhí)行的活動列表,也稱為待辦事項列表。此類列表通常在紙張、文本編輯器、電子表格等上創(chuàng)建。Microsoft 還為您提供了創(chuàng)建和管理待辦事項列表并將其稱為任務(wù)的功能。在本文中,我們將介紹如何使用 C# 以編程方式在 MS Exchange Server 上添加、更新或刪除任務(wù)。
在 MS Exchange Server 上創(chuàng)建、更新或刪除任務(wù),我們將使用Aspose.Email for .NET。它是一個功能豐富的 API,用于創(chuàng)建電子郵件客戶端應(yīng)用程序并與 MS Exchange Server 一起工作,而無需編寫復(fù)雜的代碼。您可以 下載 API 的 DLL 或 使用以下命令從NuGet安裝它。
PM> Install-Package Aspose.Email
以下是在 C# .NET 中在 MS Exchange Server 上創(chuàng)建任務(wù)的步驟。
以下代碼示例展示了如何使用 C# 在 MS Exchange Server 上創(chuàng)建任務(wù)。
// Create instance of EWSClient class by giving credentials IEWSClient client = EWSClient.GetEWSClient("http://outlook.office365.com/ews/exchange.asmx", "testUser", "pwd", "domain"); // Create Exchange task object ExchangeTask task = new ExchangeTask(); // Set task subject and status (or other properties) task.Subject = "New-Test"; task.Status = ExchangeTaskStatus.InProgress; // Create task client.CreateTask(client.MailboxInfo.TasksUri, task);
您還可以使用 C# 以編程方式訪問和更新 MS Exchange Server 上的現(xiàn)有任務(wù)。以下是執(zhí)行此操作的步驟。
以下代碼示例顯示了如何在 C# 中更新 MS Exchange Server 上的任務(wù)。
// Create and initialize credentials var credentials = new NetworkCredential("username", "12345"); // Create instance of ExchangeClient class by giving credentials IEWSClient client = EWSClient.GetEWSClient("http://outlook.office365.com/ews/exchange.asmx", "testUser", "pwd", "domain"); // Get tasks info collection from exchange ExchangeMessageInfoCollection tasks = client.ListMessages(client.MailboxInfo.TasksUri); // Parse all the tasks in the list foreach (ExchangeMessageInfo info in tasks) { // Fetch task from exchange using current task info ExchangeTask task = client.FetchTask(info.UniqueUri); // Update the task status task.Status = ExchangeTaskStatus.NotStarted; // Set the task due date task.DueDate = new DateTime(2013, 2, 26); // Set task priority task.Priority = MailPriority.Low; // Update task on exchange client.UpdateTask(task); }
以下是在 C# 中刪除 MS Exchange 服務(wù)器上的任務(wù)的步驟。
以下代碼示例展示了如何在 C# 中從 MS Exchange Server 中刪除任務(wù)。
// Create instance of ExchangeClient class by giving credentials IEWSClient client = EWSClient.GetEWSClient("http://outlook.office365.com/ews/exchange.asmx", "testUser", "pwd", "domain"); // Get tasks collection from exchange ExchangeMessageInfoCollection tasks = client.ListMessages(client.MailboxInfo.TasksUri); // Parse all the tasks in the list foreach (ExchangeMessageInfo info in tasks) { // Fetch task from exchange using current task info ExchangeTask task = client.FetchTask(info.UniqueUri); // Check if the current task fulfills the criteria if (task.Subject.Equals("test")) { // Delete task from exchange client.DeleteItem(task.UniqueUri, DeletionOptions.DeletePermanently); } }
在本文中,您學習了如何在 Microsoft Exchange Server 上管理任務(wù)。特別是,您已經(jīng)了解了如何使用 C# 以編程方式在 MS Exchange Server 上添加、更新或刪除任務(wù)。此外,您還可以瀏覽 文檔 以閱讀有關(guān) Aspose.Email for .NET 的更多信息。此外,您可以通過在線客服或加入群聊提出您的問題。
歡迎下載|體驗更多Aspose產(chǎn)品
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請郵件反饋至chenjj@fc6vip.cn