Various people create a list of activities to be performed, which is also known as a to-do list. Such lists are usually created on a paper, text editor, spreadsheets, etc. Microsoft also provides you the feature of creating and managing to-do lists and terms them as tasks. In this article, we will cover how to add, update, or delete tasks on MS Exchange Server programmatically in C#.
- .NET API to Manage Tasks on MS Exchange Server
- Create a Task on MS Exchange Server in C#
- Update a Task on MS Exchange Server in C#
- Delete Tasks on MS Exchange Server in C#
.NET API to Manage Tasks on MS Exchange Server
To create, update, or delete tasks on MS Exchange Server, we will use Aspose.Email for .NET. It is a feature-rich API to create email client applications and work with MS Exchange Server without writing complex code. You can either download the API’s DLL or install it from NuGet using the following command.
PM> Install-Package Aspose.Email
Create a Task on MS Exchange Server in C#
The following are the steps to create tasks on MS Exchange Server in C# .NET.
- First, connect to Exchange Server and get the instance of the EWS client into an IEWSClient object.
- Then, create an instance of ExchangeTask class.
- Set properties of tasks such as subject, status, etc.
- Finally, create task using IEWSClient.CreateTask(IEWSClient.MailboxInfo.TasksUri, ExchangeTask) method.
The following code sample shows how to create tasks on MS Exchange Server using C#.
Update Task on MS Exchange Server in C#
You can also access and update the existing tasks on MS Exchange Server programmatically using C#. The following are the steps to perform this operation.
- First, connect to Exchange Server and get the instance of the EWS client into an IEWSClient object.
- Then, get lists of tasks into an ExchangeMessageInfoCollection object using IEWSClient.ListMessages(IEWSClient.MailboxInfo.TasksUri) method.
- Loop through each ExchangeMessageInfo in the collection.
- Fetch each ExchangeTask using IEWSClient.FetchTask(ExchangeMessageInfo.UniqueUri) method and filter the required one(s).
- Finally, edit properties and update the task using IEWSClient.UpdateTask(ExchangeTask) method.
The following code sample shows how to update a task on MS Exchange Server in C#.
Delete Tasks on MS Exchange Server in C#
The following are the steps to delete tasks on MS Exchange server in C#.
- First, connect to Exchange Server and get the instance of the EWS client into an IEWSClient object.
- Then, get lists of tasks into an ExchangeMessageInfoCollection object using IEWSClient.ListMessages(IEWSClient.MailboxInfo.TasksUri) method.
- Loop through each ExchangeMessageInfo in the collection.
- Fetch each ExchangeTask using IEWSClient.FetchTask(ExchangeMessageInfo.UniqueUri) method and filter the required one(s).
- Finally, delete the task using IEWSClient.DeleteItem(ExchangeTask.UniqueUri, DeletionOptions.DeletePermanently) method.
The following code sample shows how to delete tasks from MS Exchange Server in C#.
Get a Free API License
You can get a free temporary license to use Aspose.Email for .NET without evaluation limitations.
Conclusion
In this article, you have learned how to manage tasks on Microsoft Exchange Server. Particularly, you have seen how to add, update, or delete tasks on MS Exchange Server programmatically in C#. Alongside, you can explore the documentation to read more about Aspose.Email for .NET. Also, you can ask your questions via our forum.