private HashSet<String> returnSubfolders( Folder folder ) throws KettleException { HashSet<String> list = new HashSet<String>(); try { if ( ( folder.getType() & Folder.HOLDS_FOLDERS ) != 0 ) { Folder[] f = folder.list(); for ( int i = 0; i < f.length; i++ ) { // Search for sub folders if ( ( f[i].getType() & Folder.HOLDS_FOLDERS ) != 0 ) { list.add( f[i].getFullName() ); list.addAll( returnSubfolders( f[i] ) ); } } } } catch ( MessagingException m ) { throw new KettleException( m ); } return list; }
/** * Returns array of all {@link Folder}s as {@code String}s. You can use these names in * {@link #useFolder(String)} method. * * @return array of all {@link Folder}s as {@code String}s. */ public String[] getAllFolders() { final Folder[] folders; try { folders = getService().getDefaultFolder().list("*"); } catch (final MessagingException msgexc) { throw new MailException("Failed to connect to folder", msgexc); } final String[] folderNames = new String[folders.length]; for (int i = 0; i < folders.length; i++) { final Folder folder = folders[i]; folderNames[i] = folder.getFullName(); } return folderNames; }
private void buildFoldersTree( Folder folder, TreeItem parentTreeItem, boolean topfolder ) throws MessagingException { if ( ( folder.getType() & Folder.HOLDS_FOLDERS ) != 0 ) { Folder[] f = folder.list(); for ( int i = 0; i < f.length; i++ ) { tiTree = topfolder ? new TreeItem( wTree, SWT.NONE ) : new TreeItem( parentTreeItem, SWT.NONE ); tiTree.setImage( guiresource.getImageBol() ); tiTree.setText( f[i].getName() ); // Search for sub folders if ( ( f[i].getType() & Folder.HOLDS_FOLDERS ) != 0 ) { buildFoldersTree( f[i], tiTree, false ); } } } }
/** * Convenience method that returns the list of folders under this * Folder. This method just calls the <code>list(String pattern)</code> * method with <code>"%"</code> as the match pattern. This method can * be invoked on a closed Folder. * * @return array of Folder objects under this Folder. An * empty array is returned if no subfolders exist. * @see #list * @exception FolderNotFoundException if this folder does * not exist. * @exception MessagingException for other failures */ public Folder[] list() throws MessagingException { return list("%"); }
/** * Convenience method that returns the list of folders under this * Folder. This method just calls the <code>list(String pattern)</code> * method with <code>"%"</code> as the match pattern. This method can * be invoked on a closed Folder. * * @return array of Folder objects under this Folder. An * empty array is returned if no subfolders exist. * @see #list * @exception FolderNotFoundException if this folder does * not exist. * @exception MessagingException for other failures */ public Folder[] list() throws MessagingException { return list("%"); }
return list(pattern);
return list(pattern);
/** * Convenience method that invokes {@link #list(String)} with the pattern "%". * * @return a, possibly empty, array of subfolders * @throws MessagingException if there was a problem accessing the store */ public Folder[] list() throws MessagingException { return list("%"); }
/** * Convenience method that invokes {@link #list(String)} with the pattern "%". * * @return a, possibly empty, array of subfolders * @throws MessagingException if there was a problem accessing the store */ public Folder[] list() throws MessagingException { return list("%"); }
/** * Return a list of folders to which the user is subscribed and which match the supplied pattern. * If the store does not support the concept of subscription then this should match against * all folders; the default implementation of this method achieves this by defaulting to the * {@link #list(String)} method. * * @param pattern the pattern to search for * @return a, possibly empty, array containing subscribed Folders that matched the pattern * @throws MessagingException if there was a problem accessing the store */ public Folder[] listSubscribed(String pattern) throws MessagingException { return list(pattern); }
/** * Return a list of folders to which the user is subscribed and which match the supplied pattern. * If the store does not support the concept of subscription then this should match against * all folders; the default implementation of this method achieves this by defaulting to the * {@link #list(String)} method. * * @param pattern the pattern to search for * @return a, possibly empty, array containing subscribed Folders that matched the pattern * @throws MessagingException if there was a problem accessing the store */ public Folder[] listSubscribed(String pattern) throws MessagingException { return list(pattern); }
/** * Convenience method that returns the list of folders under this * Folder. This method just calls the <code>list(String pattern)</code> * method with <code>"%"</code> as the match pattern. This method can * be invoked on a closed Folder. * * @return array of Folder objects under this Folder. An * empty array is returned if no subfolders exist. * @see #list * @exception FolderNotFoundException if this folder does * not exist. * @exception MessagingException for other failures */ public Folder[] list() throws MessagingException { return list("%"); }
public ListMatrix<Folder> getSubFolders(Folder folder) throws Exception { Folder[] folders = folder.list(); ListMatrix<Folder> folderMatrix = new DefaultListMatrix<Folder>(Arrays.asList(folders)); return folderMatrix; }
Folder[] f = store.getDefaultFolder().list(); for(Folder fd:f){ Folder t[]=fd.list(); System.out.println("-------"+fd.getName()+"------"); for(Folder f1:t) System.out.println("->"+f1.getName()); }
@Override public JavaxMailFolder[] list(String pattern) throws RuntimeMessagingException { try { return decorateFolderArray(delegate.list(pattern)); } catch (MessagingException e) { throw new RuntimeMessagingException(e); } }
@Override public JavaxMailFolder[] list() throws RuntimeMessagingException { try { return decorateFolderArray(delegate.list()); } catch (MessagingException e) { throw new RuntimeMessagingException(e); } }
Session session = Session.getDefaultInstance(System.getProperties(),null); Store store = session.getStore("imaps"); store.connect(this.host, this.userName, this.password); // Get default folder Folder folder = store.getDefaultFolder(); // Get any folder by name Folder[] folderList = folder.list();
protected void recurseFolders(final Folder folder) { // folder can hold messages if ((folder.getType() & Folder.HOLDS_MESSAGES) != 0) { // process them } // folder can hold other folders if ((folder.getType() & Folder.HOLDS_FOLDERS) != 0) { for (final Folder subfolder : folder.list()) { // process them recursive recurseFolders(subfolder); } } }
public void eachFolder(String folderName, String folderPattern, Closure closure) throws Exception { WithContext<Object> action = ctx -> { Folder folder = ctx.store.getFolder(folderName); if (folder.exists()) { folder.open(Folder.READ_ONLY); Folder[] folders = folder.list(folderPattern); for (Folder f : folders) { closure.call(f); } folder.close(false); } return null; }; performWithContext(action); }
/** * {@inheritDoc} */ public synchronized void close() throws MessagingException { Folder[] folders = getDefaultFolder().list(); for (Folder folder : folders) { if (folder.isOpen()) { folder.close(false); } } protocolHandler.disconnect(); super.close(); } }