العمل مع المجلدات على WebDav
Contents
[
Hide
]
قائمة جميع المجلدات من الخادم
توفر Aspose.Email API القدرة على الاتصال بخادم Exchange وسرد جميع المجلدات والمجلدات الفرعية. يمكنك أيضًا استرجاع جميع المجلدات الفرعية من كل مجلد بشكل متكرر. توضح هذه المقالة كيفية استرجاع جميع المجلدات الفرعية من خادم Exchange واسترجاع المجلدات باستخدام الترميز الصفحي.
استخدام WebDav
المقتطف البرمجي التالي يوضح لك كيفية سرد المجلدات من خادم Exchange.
public static void run() {
try {
ExchangeClient client = new ExchangeClient("http://ex07sp1/exchange/Administrator", "user", "pwd", "domain");
System.out.println("Downloading all messages from Inbox....");
ExchangeMailboxInfo mailboxInfo = client.getMailboxInfo();
System.out.println("Mailbox URI: " + mailboxInfo.getMailboxUri());
String rootUri = client.getMailboxInfo().getRootUri();
// List all the folders from Exchange server
ExchangeFolderInfoCollection folderInfoCollection = client.listSubFolders(rootUri);
for (ExchangeFolderInfo folderInfo : folderInfoCollection) {
// Call the recursive method to read messages and get sub-folders
listSubFolders(client, folderInfo);
}
System.out.println("All messages downloaded.");
} catch (Exception ex) {
System.err.println(ex);
}
}
private static void listSubFolders(ExchangeClient client, ExchangeFolderInfo folderInfo) {
System.out.println(folderInfo.getDisplayName());
try {
// If this folder has sub-folders, call this method recursively to get messages
ExchangeFolderInfoCollection folderInfoCollection = client.ListSubFolders(folderInfo.Uri);
for (ExchangeFolderInfo subfolderInfo : folderInfoCollection) {
listSubFolders(client, subfolderInfo);
}
} catch (Exception ex) {
System.err.println(ex);
}
}