Create and Delete Folders on MS Exchange Server in C#

Create and Delete Folders on MS Exchange Server in C#

In Microsoft Exchange Server, emails are organized in different folders such as inbox, outbox, etc. Also, you can create your own folders or subfolders based on your needs. While working with MS Exchange Server, you may need to create custom folders programmatically. In this article, you will learn how to create folders or subfolders with EWS on MS Exchange Server in C# .NET. Also, we will cover how to delete a folder on Exchange Server.

C# .NET API to Create Folders on MS Exchange Server

To manage folders with EWS on MS Exchange Server, we will utilize Aspose.Email for .NET. The API makes it quite easier to work with the Exchange Server’s services from within .NET applications. You can either download the API’s DLL or install it from NuGet using the following command.

PM> Install-Package Aspose.Email

Create a Folder on MS Exchange Server in C#

The following are the steps to create a folder on MS Exchange Server in C#.

The following code sample shows how to create a folder on MS Exchange Server with EWS in C#.

Create a Subfolder on MS Exchange Server in C#

To create a subfolder, you would first need to check if the parent folder exists or not. If it does, simply create the subfolder, else create the parent folder first. The following steps demonstrate how to create a subfolder on MS Exchange Server in C#.

The following code sample shows how to create a subfolder on MS Exchange Server in C#.

Delete a Folder on MS Exchange Server in C#

The following are the steps to delete a folder on MS Exchange Server in C#.

The following code sample shows how to delete a folder on 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 work with folders on Microsoft Exchange Server with EWS in C#. With the help of code samples, you have seen how to create and delete a particular folder on MS Exchange Server programmatically in C#. Besides, you can explore the documentation to read more about Aspose.Email for .NET. Also, you can ask your questions via our forum.

See Also