Is there a way to read emails from a custom folder in MS-Exchange using Java? I'm able to read from the Inbox, but I have custom folder names where the emails are moved to that I'd like to have the code read in those folders.
Below is my current code to read from Inbox:
ExchangeCredentials credentials = new WebCredentials("userName", "passWORD", "domain");
service.setCredentials(credentials);
service.setUrl(new URI("https://outlook.mycompany.com/ews/exchange.asmx"));
ItemView view = new ItemView(200);
FindItemsResults<Item> findResults = service.findItems(WellKnownFolderName.Inbox , view);
Instead I want something like this:
FindItemsResults<Item> findResults = service.findItems("My Custom Folder" , view);
I've tried with this, but it didn't work:
FindItemsResults<Item> findResults = service.findItems(FolderId.getFolderIdFromString("My Custom Folder") , view);