當前位置: 首頁>>代碼示例>>Java>>正文


Java Folder.list方法代碼示例

本文整理匯總了Java中javax.mail.Folder.list方法的典型用法代碼示例。如果您正苦於以下問題:Java Folder.list方法的具體用法?Java Folder.list怎麽用?Java Folder.list使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.mail.Folder的用法示例。


在下文中一共展示了Folder.list方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getEmail

import javax.mail.Folder; //導入方法依賴的package包/類
public void getEmail() throws MessagingException, IOException {
    Session session = Session.getDefaultInstance(System.getProperties(),null);
    Store store = null;
    store = session.getStore("imaps");

    // store.connect(this.host, this.userName, this.password);

    // Get default folder
    Folder folder = store.getDefaultFolder();
    folder.getMessages();
    folder.getNewMessageCount();
    Message m = folder.getMessage(0);
    m.getMessageNumber();
    m.getAllRecipients();
    m.getReceivedDate();
    m.getFrom();
    m.getSubject();
    m.getReplyTo();
    m.getContent();
    m.getSize();

    // Get any folder by name
    Folder[] folderList = folder.list();
}
 
開發者ID:victordiaz,項目名稱:phonk,代碼行數:25,代碼來源:PNetwork.java

示例2: receiveByFolder

import javax.mail.Folder; //導入方法依賴的package包/類
public void receiveByFolder(Folder folder, JavamailConfig javamailConfig)
        throws MessagingException, IOException {
    logger.info("receive : {}", folder);

    if ((Folder.HOLDS_MESSAGES & folder.getType()) != 0) {
        this.receiveMessageByFolder(folder, javamailConfig);
    }

    if ((Folder.HOLDS_FOLDERS & folder.getType()) != 0) {
        for (Folder childFolder : folder.list()) {
            this.receiveByFolder(childFolder, javamailConfig);
        }
    }

    if (folder.isOpen()) {
        // 關閉資源
        folder.close(false);
    }
}
 
開發者ID:zhaojunfei,項目名稱:lemon,代碼行數:20,代碼來源:JavamailService.java

示例3: printFolders

import javax.mail.Folder; //導入方法依賴的package包/類
private static void printFolders(Folder folder) throws MessagingException {
		System.out.println(folder.getFullName() + " - " + folder.getName());
		Folder[] childs = folder.list();
		System.out.println("************childs***************");
		for (int i = 0; i < childs.length; i++) {
			printFolders(childs[i]);
		}
		

//		Folder[] personalNamespaces = store.getPersonalNamespaces();
//		System.out.println("************personalNamespaces***************");
//		for (int i = 0; i < personalNamespaces.length; i++) {
//			System.out.println(personalNamespaces[i].getFullName() + " - " + personalNamespaces[i].getName());
//		}
//		
//		Folder[] sharedNamespaces = store.getSharedNamespaces();
//		System.out.println("************sharedNamespaces***************");
//		for (int i = 0; i < sharedNamespaces.length; i++) {
//			System.out.println(sharedNamespaces[i].getFullName() + " - " + sharedNamespaces[i].getName());
//		}
	}
 
開發者ID:Ardulink,項目名稱:Ardulink-1,代碼行數:22,代碼來源:MailListener.java

示例4: clear

import javax.mail.Folder; //導入方法依賴的package包/類
private static void clear(Folder folder) throws MessagingException {
	if(folder.exists() && (folder.getType() & Folder.HOLDS_MESSAGES) == Folder.HOLDS_MESSAGES) {
		int totMessages = folder.getMessageCount();
		System.out.println(totMessages + " messages from folder: " + folder.getFullName());
		folder.open(Folder.READ_WRITE);
		Message[] messages = folder.getMessages();
		for (int i = 0; i < messages.length; i++) {
			System.out.println("Deleting message: " + (i+1) + " of " + totMessages);
			messages[i].setFlag(Flags.Flag.DELETED, true);
		}
		folder.close(true);
	}
	Folder[] childs = folder.list();
	for (int i = 0; i < childs.length; i++) {
		clear(childs[i]);
	}
}
 
開發者ID:Ardulink,項目名稱:Ardulink-1,代碼行數:18,代碼來源:MailListener.java

示例5: main

import javax.mail.Folder; //導入方法依賴的package包/類
public static void main(String[] argv) throws Exception {
    String fileName = MailConstants.PROPS_FILE_NAME;
    String protocol = null;
    String host = null;
    String user = null;
    String password = null;
    String root = null;

    // If argc == 1, assume it's a Properties file.
    if (argv.length == 1) {
        fileName = argv[0];
        FileProperties fp = new FileProperties(fileName);
        fp.load();
        protocol = fp.getProperty(MailConstants.RECV_PROTO);
        host = fp.getProperty(MailConstants.RECV_HOST);
        user = fp.getProperty(MailConstants.RECV_USER);
        password = fp.getProperty(MailConstants.RECV_PASS);
        root = fp.getProperty(MailConstants.RECV_ROOT);
    }
    // If not, assume listing all args in long form.
    else if (argv.length == 5) {
        protocol = argv[0];
        host = argv[1];
        user = argv[2];
        password = argv[3];
        root = argv[4];
    }
    // Otherwise give up.
    else {
        System.err.println(
            "Usage: MailLister protocol host user pw root");
        System.exit(0);
    }

    boolean recursive = false;

    // Start with a JavaMail Session object
    Session session = Session.getDefaultInstance(
        System.getProperties(), null);
    session.setDebug(false);

    // Get a Store object for the given protocol
    Store store = session.getStore(protocol);
    if (password.equals("*")) {
        final char[] passBytes = 
            System.console().readPassword("Password:", (Object[])null);
        password = new String(passBytes);
    }
    store.connect(host, user, password);

    // Get Folder object for root, and list it
    // If root name = "", getDefaultFolder(), else getFolder(root)
    Folder rf;
    if (root.length() != 0) {
        System.out.println("Getting folder " + root + ".");
        rf = store.getFolder(root);
    } else {
        System.out.println("Getting default folder.");
        rf = store.getDefaultFolder();
    }
    rf.open(Folder.READ_WRITE);

    if (rf.getType() == Folder.HOLDS_FOLDERS) {
        Folder[] fs = rf.list();
        for (Folder f : fs) {
            listFolder(f, "", recursive);
        }
    } else {
        listFolder(rf, "", false);
    }
}
 
開發者ID:shashanksingh28,項目名稱:code-similarity,代碼行數:72,代碼來源:MailLister.java

示例6: listFolder

import javax.mail.Folder; //導入方法依賴的package包/類
static void listFolder(Folder folder, String tab, boolean recurse)
throws Exception {
    folder.open(Folder.READ_WRITE);
    System.out.println(tab + "Name: " + folder.getName() + '(' +
        folder.getFullName() + ')');
    if (!folder.isSubscribed())
        System.out.println(tab + "Not Subscribed");
    if ((folder.getType() & Folder.HOLDS_MESSAGES) != 0) {
        if (folder.hasNewMessages())
            System.out.println(tab + "Has New Messages");
        else
            System.out.println(tab + "No New Messages");
        Message[] msgs = folder.getMessages();
        for (Message m : msgs) {
            Address from = m.getFrom()[0];
            String fromAddress;
            if (from instanceof InternetAddress)
                fromAddress = ((InternetAddress)from).getAddress();
            else
                fromAddress = from.toString();
            StringBuffer sb = new StringBuffer();
            fromFmt.format(fromAddress, sb, null);
            sb.    append("  ");
            subjFmt.format(m.getSubject(), sb, null);
            System.out.println(sb.toString());
        }
    }
    if ((folder.getType() & Folder.HOLDS_FOLDERS) != 0) {
        System.out.println(tab + "Is Directory");
    }
    if (recurse) {
        Folder[] fs = folder.list();
        for (Folder f : fs) {
            listFolder(f, tab + "", recurse);
        }
    }
}
 
開發者ID:shashanksingh28,項目名稱:code-similarity,代碼行數:38,代碼來源:MailLister.java

示例7: addNotificationSourcesToList

import javax.mail.Folder; //導入方法依賴的package包/類
private void addNotificationSourcesToList(GmailFolder parent, Folder folder, ArrayList<GmailFolder> sources, boolean includeParent) {
	GmailFolder source = new GmailFolder(this, parent, folder);
	if (includeParent)
		sources.add(source);
	try {
		Folder[] children = folder.list();
		for (Folder child : children) {
			addNotificationSourcesToList(includeParent ? source : null, child, sources, true);
		}
	} catch (Exception e) {
		e.printStackTrace();
	}
}
 
開發者ID:mathieulegoc,項目名稱:SmartTokens,代碼行數:14,代碼來源:GmailReader.java

示例8: clearMainFolder

import javax.mail.Folder; //導入方法依賴的package包/類
private static void clearMainFolder(Folder folder) throws MessagingException {
	System.out.println("Deleting old messages...");
	Folder[] childs = folder.list();
	for (int i = 0; i < childs.length; i++) {
		clear(childs[i]);
	}
	clear(folder);
	System.out.println("Messages deleted.");
}
 
開發者ID:Ardulink,項目名稱:Ardulink-1,代碼行數:10,代碼來源:MailListener.java

示例9: getSubFolders

import javax.mail.Folder; //導入方法依賴的package包/類
public ListMatrix<Folder> getSubFolders(Folder folder) throws Exception {
	Folder[] folders = folder.list();
	ListMatrix<Folder> folderMatrix = new DefaultListMatrix<Folder>(Arrays.asList(folders));
	return folderMatrix;
}
 
開發者ID:ujmp,項目名稱:universal-java-matrix-package,代碼行數:6,代碼來源:ImapUtil.java

示例10: listFolder

import javax.mail.Folder; //導入方法依賴的package包/類
public cfQueryResultData listFolder( cfImapConnection imapConnection, String rootFolder) throws cfmRunTimeException {
	
	cfQueryResultData query	= new cfQueryResultData( new String[]{"fullname","name","totalmessages","unread","new"},"CFIMAP" );						

	try{
	
		Folder	folderToList;

		if ( rootFolder == null || rootFolder.length() == 0 )
			folderToList = imapConnection.mailStore.getDefaultFolder();
		else
			folderToList = imapConnection.mailStore.getFolder(rootFolder);
			
		if ( (folderToList.getType() & Folder.HOLDS_FOLDERS) != 0){
			Folder[] folderArray = folderToList.list();
			
			query.addRow( folderArray.length );				
			
			for (int i = 0; i < folderArray.length; i++)
				folderRow( query, i+1, folderArray[i] );
		}

	}catch(Exception E){}
	
	return query;
}
 
開發者ID:OpenBD,項目名稱:openbd-core,代碼行數:27,代碼來源:cfMailFolderData.java

示例11: listAllFolders

import javax.mail.Folder; //導入方法依賴的package包/類
public cfQueryResultData listAllFolders( cfImapConnection imapConnection) throws cfmRunTimeException {
	cfQueryResultData query	= new cfQueryResultData( new String[]{"fullname","name","totalmessages","unread","new"},"CFIMAP" );						
	
	try{
		Folder	folderToList;
		folderToList = imapConnection.mailStore.getDefaultFolder();

		if ( (folderToList.getType() & Folder.HOLDS_FOLDERS) != 0){
			Folder[] folderArray = folderToList.list("*");
			query.addRow( folderArray.length );				
			
			for (int i = 0; i < folderArray.length; i++)
				folderRow( query, i+1, folderArray[i] );
		}

	}catch(Exception E){}
	
	return query;
}
 
開發者ID:OpenBD,項目名稱:openbd-core,代碼行數:20,代碼來源:cfMailFolderData.java


注:本文中的javax.mail.Folder.list方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。