Working with Folders on Exchange Server
List Folders from Exchange Server
List Folders with Paging Support
For a large number of folders on Exchange Server, it might not be convenient to retrieve all the folders list at once. Aspose.Email for Java API lets you list folders from the Exchange server with paging support. The following example demonstrates the usage of this API feature.
Getting Folder Type Information using EWS
Creating Folders and Sub-Folders using EWS
Synchronizing Folder Items using EWS
Access Mailbox Custom Folders or Subfolders
In the following example, a custom folder named “TestInbox”, which is created under INBOX is accessed and all the messages are displayed from this custom folder.
To perform this task, the following are the steps:
- Initialize the IEWSClient object by providing valid credentials.
- Access the default mailbox.
- Access the parent folder, which is INBOX in this example. This parent folder can also be a custom folder itself.
- Use folderExists() to search the specified custom subfolder, for example “TestInbox”. It will return the URI of “TestInbox”.
- Use this Uri to access all the messages in that custom folder.
Retrieve Folder Permissions using EWS Client
Users are assigned permissions to public folders on Exchange Server, which limits/determine the level of access a user has to these folders. The ExchangeFolderPermission class provides a set of permission properties for Exchange folders such as the permission level, whether they can create items, deleting items, and perform other tasks as specified by the permission properties. Permissions can be retrieved using the getFolderPermisssions() method of IEWSClient.
This article shows how to retrieve the permissions applied to a public folder for all the users who have access to the shared folders.
The following example shows how to use the EWSClient class to retrieve permissions applied to a folder.
To perform this task:
- Initialize the EWSClient.
- Use the listPublicFolders() to get a list of all public folders.
- Retrieve the permissions associated with a folder using the getFolderPermissions() method.
Download Messages from Public Folders of Exchange Server
The sample source code below reads all public folders, and subfolders, and lists and downloads any messages found in these folders. This example only works with Microsoft Exchange Server 2007 or above since only these support EWS.
Backup Exchange Folders to PST
In order to take a backup of Exchange server folders, the following steps may be followed.