OfficeDev / ews-java-api

A java client library to access Exchange web services. The API works against Office 365 Exchange Online as well as on premises Exchange.
MIT License
868 stars 559 forks source link

cant get out the folders. No mailbox with such guid. #762

Open willdomybest opened 2 years ago

willdomybest commented 2 years ago

ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010_SP1); ExchangeCredentials credentials = new WebCredentials("xxx", "xxx"); service.setUrl(new URI("https://mail.xxx.com/EWS/Exchange.asmx")); service.setCredentials(credentials); Folder msgFolderRoot = Folder.bind(service, WellKnownFolderName.Root); int childFolderCount = msgFolderRoot.getChildFolderCount(); FolderView folderView = new FolderView(childFolderCount); FindFoldersResults findResults = msgFolderRoot.findFolders(folderView); for (Folder folder : findResults.getFolders()) { System.out.println("Count======" + folder.getChildFolderCount()); System.out.println("Name=======" + folder.getDisplayName()); }

Log: Exception in thread "main" microsoft.exchange.webservices.data.core.exception.service.remote.ServiceResponseException: No mailbox with such guid. at microsoft.exchange.webservices.data.core.response.ServiceResponse.internalThrowIfNecessary(ServiceResponse.java:278) at microsoft.exchange.webservices.data.core.response.ServiceResponse.throwIfNecessary(ServiceResponse.java:267) at microsoft.exchange.webservices.data.core.request.MultiResponseServiceRequest.execute(MultiResponseServiceRequest.java:165) at microsoft.exchange.webservices.data.core.ExchangeService.bindToFolder(ExchangeService.java:504) at microsoft.exchange.webservices.data.core.ExchangeService.bindToFolder(ExchangeService.java:523) at microsoft.exchange.webservices.data.core.service.folder.Folder.bind(Folder.java:98) at microsoft.exchange.webservices.data.core.service.folder.Folder.bind(Folder.java:147)