翻譯|使用教程|編輯:胡濤|2022-04-18 11:46:22.773|閱讀 297 次
概述:在本文中,我們將介紹如何使用 C# 以編程方式在 MS Exchange Server 上添加、更新或刪除任務。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關鏈接:
不同的人創建要執行的活動列表,也稱為待辦事項列表。此類列表通常在紙張、文本編輯器、電子表格等上創建。Microsoft 還為您提供了創建和管理待辦事項列表并將其稱為任務的功能。在本文中,我們將介紹如何使用 C# 以編程方式在 MS Exchange Server 上添加、更新或刪除任務。
在 MS Exchange Server 上創建、更新或刪除任務,我們將使用Aspose.Email for .NET。它是一個功能豐富的 API,用于創建電子郵件客戶端應用程序并與 MS Exchange Server 一起工作,而無需編寫復雜的代碼。您可以 下載 API 的 DLL 或 使用以下命令從NuGet安裝它。
PM> Install-Package Aspose.Email
以下是在 C# .NET 中在 MS Exchange Server 上創建任務的步驟。
以下代碼示例展示了如何使用 C# 在 MS Exchange Server 上創建任務。
// 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 上的現有任務。以下是執行此操作的步驟。
以下代碼示例顯示了如何在 C# 中更新 MS Exchange Server 上的任務。
// 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 服務器上的任務的步驟。
以下代碼示例展示了如何在 C# 中從 MS Exchange Server 中刪除任務。
// 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 上管理任務。特別是,您已經了解了如何使用 C# 以編程方式在 MS Exchange Server 上添加、更新或刪除任務。此外,您還可以瀏覽 文檔 以閱讀有關 Aspose.Email for .NET 的更多信息。此外,您可以通過在線客服或加入群聊提出您的問題。
歡迎下載|體驗更多Aspose產品
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn