קבלת מידע על תיקיות מתיבת דואר IMAP
Contents
[
Hide
]
Aspose.Email - קבלת מידע על תיקיות מתיבת דואר IMAP
קבלת מידע על תיקיות משרת IMAP היא קלה מאוד עם Aspose.Email. השיטה listFolders() של ImapClient מחזירה אובייקט מסוג ImapFolderInfoCollection המכיל מידע על כל תיקיות השרת. ניתן לעבור על אוסף זה ולקבל מידע על כל תיקייה בנפרד בלולאה. לשיטה יש גרסאות מרובות. ניתן להעביר שם תיקייה כפרמטר כדי לקבל רשימת תיקיות משנה.
Java
ImapClient client = new ImapClient();
client.setHost("--server--"); //imap.secureserver.net,
client.setPort(993);
client.setUsername("--username--");
client.setPassword("--password--");
client.setSecurityOptions(SecurityOptions.Auto);
ImapFolderInfoCollection folderInfoColl = client.listFolders();
// Iterate through the collection to get folder info one by one
for (ImapFolderInfo folderInfo:folderInfoColl)
{
// Folder name
System.out.println("Folder name is: " + folderInfo.getName());
ImapFolderInfo folderExtInfo = client.listFolder(folderInfo.getName());
// New messages in the folder
System.out.println("New message count: " + folderExtInfo.getNewMessageCount());
// Check whether its read only
System.out.println("Is it readonly? " + folderExtInfo.getReadOnly());
// Total number of messages
System.out.println("Total number of messages: " + folderExtInfo.getTotalMessageCount());
}
הורד קוד רץ
הורד את Get Folders Information from IMAP Mailbox מאתרי הקוד החברתי המופיעים למטה: