protected Folder getFolder(ExchangeService service) { Folder folder; if(folderName.equals("INBOX")){ try { folder = Folder.bind(service, WellKnownFolderName.Inbox); } catch (Exception e) { throw new ProcessException("Failed to bind Inbox Folder on EWS Server", e); } } else { FolderView view = new FolderView(10); view.setTraversal(FolderTraversal.Deep); SearchFilter searchFilter = new SearchFilter.IsEqualTo(FolderSchema.DisplayName, folderName); try { FindFoldersResults foldersResults = service.findFolders(WellKnownFolderName.Root,searchFilter, view); ArrayList<Folder> folderIds = foldersResults.getFolders(); if(folderIds.size() > 1){ throw new ProcessException("More than 1 folder found with the name " + folderName); } folder = Folder.bind(service, folderIds.get(0).getId()); } catch (Exception e) { throw new ProcessException("Search for Inbox Subfolder failed.", e); } } return folder; }
/** * Binds to an existing folder, whatever its actual type is, and loads the * specified set of property. Calling this method results in a call to * EWS. * * @param service , The service to use to bind to the folder. * @param id , The Id of the folder to bind to. * @return A Folder instance representing the folder corresponding to the * specified Id. * @throws Exception the exception */ public static Folder bind(ExchangeService service, FolderId id) throws Exception { return Folder.bind(service, id, PropertySet.getFirstClassProperties()); }
/** * Binds to an existing folder, whatever its actual type is, and loads the * specified set of property. Calling this method results in a call to * EWS. * * @param service The service to use to bind to the folder. * @param name The name of the folder to bind to. * @param propertySet The set of property to load. * @return A Folder instance representing the folder corresponding to the * specified Id. * @throws Exception the exception */ public static Folder bind(ExchangeService service, WellKnownFolderName name, PropertySet propertySet) throws Exception { return Folder.bind(service, new FolderId(name), propertySet); }
/** * Binds to an existing folder, whatever its actual type is, and loads the * specified set of property. Calling this method results in a call to * EWS. * * @param service The service to use to bind to the folder. * @param name The name of the folder to bind to. * @return the folder * @throws Exception the exception */ public static Folder bind(ExchangeService service, WellKnownFolderName name) throws Exception { return Folder.bind(service, new FolderId(name), PropertySet .getFirstClassProperties()); }
/** * define last message index on the server, so that on next request, we only get the newly received messages * @throws Exception */ @Override public void setLastMessageIndex() throws Exception { Folder folder = Folder.bind(service, defaultFolderId); lastMessageIndex = folder.getTotalCount(); }
/** * Binds to an existing folder, whatever its actual type is, and loads the * specified set of property. Calling this method results in a call to * EWS. * * @param service , The service to use to bind to the folder. * @param id , The Id of the folder to bind to. * @return A Folder instance representing the folder corresponding to the * specified Id. * @throws Exception the exception */ public static Folder bind(ExchangeService service, FolderId id) throws Exception { return Folder.bind(service, id, PropertySet.getFirstClassProperties()); }
/** * Binds to an existing folder, whatever its actual type is, and loads the * specified set of property. Calling this method results in a call to * EWS. * * @param service The service to use to bind to the folder. * @param name The name of the folder to bind to. * @param propertySet The set of property to load. * @return A Folder instance representing the folder corresponding to the * specified Id. * @throws Exception the exception */ public static Folder bind(ExchangeService service, WellKnownFolderName name, PropertySet propertySet) throws Exception { return Folder.bind(service, new FolderId(name), propertySet); }
/** * Binds to an existing folder, whatever its actual type is, and loads the * specified set of property. Calling this method results in a call to * EWS. * * @param service The service to use to bind to the folder. * @param name The name of the folder to bind to. * @return the folder * @throws Exception the exception */ public static Folder bind(ExchangeService service, WellKnownFolderName name) throws Exception { return Folder.bind(service, new FolderId(name), PropertySet .getFirstClassProperties()); }
protected Folder getFolder(ExchangeService service) { Folder folder; if(folderName.equals("INBOX")){ try { folder = Folder.bind(service, WellKnownFolderName.Inbox); } catch (Exception e) { throw new ProcessException("Failed to bind Inbox Folder on EWS Server", e); } } else { FolderView view = new FolderView(10); view.setTraversal(FolderTraversal.Deep); SearchFilter searchFilter = new SearchFilter.IsEqualTo(FolderSchema.DisplayName, folderName); try { FindFoldersResults foldersResults = service.findFolders(WellKnownFolderName.Root,searchFilter, view); ArrayList<Folder> folderIds = foldersResults.getFolders(); if(folderIds.size() > 1){ throw new ProcessException("More than 1 folder found with the name " + folderName); } folder = Folder.bind(service, folderIds.get(0).getId()); } catch (Exception e) { throw new ProcessException("Search for Inbox Subfolder failed.", e); } } return folder; }
Folder folder = Folder.bind(service, folderId);