import com.moyosoft.exchange.*;
import com.moyosoft.exchange.folder.*;
public class DisplayFolders
{
public static void main(String[] args) throws 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 prefix) throws ExchangeServiceException
{
for(ExchangeFolder folder : folders)
{
System.out.print(prefix + folder.getDisplayName());
System.out.println(" (" + folder.getItemsCount() + ")");
displayFolders(folder.getFolders(), prefix + " ");
}
}
}