Reputation: 77
I am trying to get Public folders email from my outlook mailbox. Presently, I can get the mails from the folders in my root folder. I use the following code for the same:
Folder rootfolder = Folder.Bind(exchange, WellKnownFolderName.MsgFolderRoot);
//Folder rootfolder = Folder.Bind(exchange, WellKnownFolderName.PublicFoldersRoot); // gives error
rootfolder.Load();
foreach (Folder folder in rootfolder.FindFolders(new FolderView(100)))
{
Console.WriteLine(folder.DisplayName);
}
When I replace WellKnownFolderName.MsgFolderRoot
with WellKnownFolderName.PublicFoldersRoot
, I get the error "There are no public folder servers available." I also referred to @Mimi Gentz solution from here, but I still get the error.
Am I missing something in my code ? Please help.
Upvotes: 0
Views: 2446
Reputation: 77
My email is on Office365 whereas public folders are OnPrem, which is why I get no public folder servers
error.
Upvotes: 0
Reputation: 22032
You need to start by adding in the correct routing headers https://learn.microsoft.com/en-us/exchange/client-developer/exchange-web-services/how-to-route-public-folder-hierarchy-requests . The other thing is that by default there won't be public folders OnPrem or Office365 so an administrator would have to have setup them up first.
Upvotes: 1