本文整理汇总了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();
}
示例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);
}
}
示例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());
// }
}
示例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]);
}
}
示例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);
}
}
示例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);
}
}
}
示例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();
}
}
示例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.");
}
示例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;
}
示例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;
}
示例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;
}