Public folder access with EWS in Exchange
Learn about how to use EWS and the EWS Managed API to access public folders and route public folder requests in Exchange.
Public folders provide a shared repository of items that users in your organization can access. Office 365, Exchange Online, and on-premises versions of Exchange starting with Exchange 2013 introduce a new architecture for public folders. Public folders in Exchange use a specialized mailbox design (instead of a public folder database) to store the public folder hierarchy and public folder content. Public folder permissions are managed through Role Based Access Control (RBAC).
Client access technologies, like Exchange Web Services (EWS) and the EWS Managed API, provide programmatic access to both the public folder hierarchy and content items in a public folder database. This article provides information about how you can use EWS and the EWS Managed API to access public folders and public folders and public folder data.
EWS operations and EWS Managed API methods for public folder access
Most of the core EWS operations support public folder access. You can use the folder and item operations and the EWS Managed API methods listed in the following table to work with public folders.
For information about EWS Managed API methods, see EWS Managed API namespaces.
EWS operation | EWS Managed API method |
---|---|
CreateFolder operation |
Folder.Save() |
UpdateFolder operation |
Folder.Update() |
DeleteFolder operation |
Folder.Delete() |
MoveFolder operation1 |
Folder.Move() |
CopyFolder operation2 |
Folder.Copy() |
GetFolder operation |
Folder.Bind() |
EmptyFolder operation3 |
Folder.Empty() |
FindFolder operation |
ExchangeService.FindFolders() Folder.FindFolders() |
CreateItem operation |
Item.Save() |
MoveItem operation |
Item.Move() |
CopyItem operation |
Item.Copy() |
UpdateItem operation |
Item.Update() |
DeleteItem operation |
Item.Delete() |
FindItem operation4 |
ExchangeService.FindItems() Folder.FindItems() |
GetItem operation |
Item.Bind() |
ConvertId operation5 |
ExchangeService.ConvertId() ExchangeService.ConvertIds() |
1 Moving folders between a public folder and private folder is not available in versions of Exchange starting with Exchange 2013.
2 This operation is only applicable to public folders in Exchange Server 2007 and Exchange Server 2010.
3 This operation is only applicable to public folders in Exchange 2010.
4 Full text indexed search within a single public folder by means of the QueryString search option is supported in versions of Exchange starting with Exchange 2013.
5 The ConvertId operation does not correctly convert public folder identifiers from the EWS identifier to the store identifier. You can manually update the identifier that is returned as a workaround.
The following operations are not supported, or are partially supported, for public folders in versions of Exchange starting with Exchange 2013:
CopyFolder (not supported). You can use CreateFolder with the CopyItems operation to implement CopyFolder operation functionality.
EmptyFolder (not supported). You can use FindItem with the DeleteItem operation to implement EmptyFolder operation functionality.
MoveFolder (partially supported). You cannot move folders between private and public folders. You can move folders between private and public folders in Exchange 2007 and Exchange 2010. You can move folders within a public folder in all versions of Exchange.
EWS and the EWS Managed API do not support the following functionality for public folders:
Using SyncFolderHierarchy. Use the FindFolder, GetFolder, FindItem and GetItem operations to synchronize items and folders in a public folder mailbox.
Deep-traversal searches of a public folder hierarchy. Use recursive FindFolder operation calls to traverse the public folder hierarchy.
Using the CreateFolderPath operation to create a folder hierarchy for public folders. You will need to use the CreateFolder operation for each folder level in a distinct folder hierarchy when you target a public folder mailbox.
Using the CreateItem operation to save copies of sent email messages. Instead, use the MoveItem operation to move a copy of the message into a public folder.
Scenarios for using EWS and the EWS Managed API to work with public folders
Public folders enable many important scenarios for Exchange mailbox users. You can empower users by using EWS and the EWS Managed API to implement custom solutions for accessing and using public folders and their contents.
Programmatically access email messages that have been sent to distribution lists
Exchange mailbox users can use public folders to store email messages that are sent to distribution lists. This is a convenient way to save distribution list history. You can use the FindItem operation in EWS or the ExchangeService.FindItems() and Folder.FindItems() methods in the EWS Managed API to access stored distribution list email messages.
Share important email messages and other mailbox items
Mailbox users can use public folders as a shared repository for mailbox items. Different users in an organization can share important email messages or contacts by using public folders. EWS can provide the access to these shared mailbox items. You can use the MoveItem operation in EWS or the Item.Move() method in the EWS Managed API to move email messages, contacts, and other mailbox items into and out of a public folder.
Public discussions with post items
Public folders are a convenient container for post items. Post items provide a way to use threaded conversations without having to send email messages between users. Users can use public folders and post items to host and maintain threaded conversations between different mailbox users in an organization. This way, mailbox users can access the shared history of a conversation that uses post items even if they were not part of the conversation. You can use the CreateItem operation in EWS or the Item.Save() method in the EWS Managed API to both create and respond to post items stored in a public folder.
Routing public folder requests
Public folder content can be stored on multiple mailbox servers. The public folder hierarchy can be stored on one mailbox, while the content for the public folder is stored on another. And each of these servers can be different than the mailbox server for the user requesting the information. In these situations, it's important to include the additional X-AnchorMailbox and X-PublicFolderMailbox headers in your public folder requests to receive accurate information about public folders.
The value for the X-AnchorMailbox and X-PublicFolderMailbox can differ depending on whether you're performing a request related to the folder hierarchy or the folder content. The following table identifies which procedure to follow for each EWS Managed API method or EWS operation.
EWS Managed API methods and EWS operations for routing public folder requests
When calling these methods | When calling these operations | Use this procedure |
---|---|---|
Folder.FindFolders Folder.Delete Folder.Update Folder.Move |
CreateFolder FindFolder DeleteFolder UpdateFolder MoveFolder |
Routing public folder hierarchy requests |
Item.Bind Item.Update Item.Copy Item.Move Item.Delete Folder.Bind Folder.FindItems |
CreateItem GetItem UpdateItem CopyItem MoveItem DeleteItem GetFolder FindItem |
Routing public folder content requests |
Version differences
In Exchange 2007 and Exchange 2010, the ConvertId operation works as expected when converting public folder identifiers from the EWS identifier to the store identifier.