List of usage examples for javax.mail Store getPersonalNamespaces
public Folder[] getPersonalNamespaces() throws MessagingException
From source file:namespace.java
public static void main(String argv[]) { int msgnum = -1; int optind;//from w w w. j av a 2s .c o m for (optind = 0; optind < argv.length; optind++) { if (argv[optind].equals("-T")) { protocol = argv[++optind]; } else if (argv[optind].equals("-H")) { host = argv[++optind]; } else if (argv[optind].equals("-U")) { user = argv[++optind]; } else if (argv[optind].equals("-P")) { password = argv[++optind]; } else if (argv[optind].equals("-D")) { debug = true; } else if (argv[optind].equals("-L")) { url = argv[++optind]; } else if (argv[optind].equals("-p")) { port = Integer.parseInt(argv[++optind]); } else if (argv[optind].equals("-u")) { suser = argv[++optind]; } else if (argv[optind].equals("--")) { optind++; break; } else if (argv[optind].startsWith("-")) { System.out.println("Usage: namespace [-L url] [-T protocol] [-H host] [-p port] [-U user]"); System.out.println("\t[-P password] [-u other-user] [-D]"); System.exit(1); } else { break; } } try { // Get a Properties object Properties props = System.getProperties(); // Get a Session object Session session = Session.getInstance(props, null); session.setDebug(debug); // Get a Store object Store store = null; if (url != null) { URLName urln = new URLName(url); store = session.getStore(urln); store.connect(); } else { if (protocol != null) store = session.getStore(protocol); else store = session.getStore(); // Connect if (host != null || user != null || password != null) store.connect(host, port, user, password); else store.connect(); } printFolders("Personal", store.getPersonalNamespaces()); printFolders("User \"" + suser + "\"", store.getUserNamespaces(suser)); printFolders("Shared", store.getSharedNamespaces()); store.close(); } catch (Exception ex) { System.out.println("Oops, got exception! " + ex.getMessage()); ex.printStackTrace(); } System.exit(0); }