Moyosoft Products | Services | Download | Contact us    
Java Bridge to Exchange
import com.moyosoft.exchange.*;
import com.moyosoft.exchange.folder.*;

public class DisplayFolders
{
  public static void main(String[] argsthrows ExchangeServiceException
  {
    // To provide hostname and credentials information, use:
    // Exchange exchange = new Exchange("hostname", "username", "password");
    Exchange exchange = ExchangeConnectionDialog.display();
    
    if(exchange == null)
    {
      return;
    }

    // Get the top folders:
    FoldersCollection folders = exchange.getTopFolders();

    // Display all the folders recursively:
    displayFolders(folders, "");
  }
  
  private static void displayFolders(FoldersCollection folders, String prefixthrows ExchangeServiceException
  {
    for(ExchangeFolder folder : folders)
    {
      System.out.print(prefix + folder.getDisplayName());
      System.out.println(" (" + folder.getItemsCount() ")");

      displayFolders(folder.getFolders(), prefix + "  ");
    }
  }
}