To-do lists are used to keep track of the activities to be performed. People create such lists on paper, text editors, spreadsheets, etc. Microsoft Exchange Server also provides the feature of creating and managing to-do lists that are composed of tasks. To work with these tasks programmatically, this article shows how to add, update, or delete tasks on MS Exchange Server in Java.
- API to Manage Tasks on MS Exchange Server
- Create a Task on MS Exchange Server in Java
- Update a Task on MS Exchange Server in Java
- Delete a Task on MS Exchange Server in Java
Java API to Manage Tasks on MS Exchange Server
Aspose.Email for Java is an email processing API that is used to create and send emails and implement email client applications. In addition, it allows you to work with MS Exchange Server seamlessly. We will use this API to create and manipulate tasks on MS Exchange Server. You can either download the API or install it using the following Maven configurations.
Repository:
<repository>
<id>AsposeJavaAPI</id>
<name>Aspose Java API</name>
<url>http://repository.aspose.com/repo/</url>
</repository>
Dependency:
<dependency>
<groupId>com.aspose</groupId>
<artifactId>aspose-email</artifactId>
<version>22.3</version>
<classifier>jdk16</classifier>
</dependency>
Create a Task on MS Exchange Server in Java
The following are the steps to create tasks on MS Exchange Server in Java.
- 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 the task using IEWSClient.createTask(String, ExchangeTask) method.
The following code sample shows how to create tasks on MS Exchange Server using Java.
Update Task on MS Exchange Server in Java
You can also access and update the existing tasks on MS Exchange Server programmatically using Java. 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(String) method.
- Loop through each ExchangeMessageInfo in the collection.
- Fetch each ExchangeTask using IEWSClient.fetchTask(String) 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 Java.
Delete Tasks on MS Exchange Server in Java
The following are the steps to delete tasks on MS Exchange Server in Java.
- 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(String) method.
- Loop through each ExchangeMessageInfo in the collection.
- Fetch each ExchangeTask using IEWSClient.fetchTask(String) method and filter the required one(s).
- Finally, delete the task using IEWSClient.deleteItem(String, DeletionOptions) method.
The following code sample shows how to delete tasks from MS Exchange Server in Java.
Get a Free API License
You can get a free temporary license to use Aspose.Email for Java 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 Java. Alongside, you can explore the documentation to read more about Aspose.Email for Java. Also, you can ask your questions via our forum.