WebDav에서 폴더 작업하기
Contents
[
Hide
]
서버에서 모든 폴더 나열
Aspose.Email API는 Exchange Server에 연결하고 모든 폴더와 하위 폴더를 나열하는 기능을 제공합니다. 또한 각 폴더에서 하위 폴더를 재귀적으로 가져올 수 있습니다. 이 문서는 Exchange 서버에서 모든 하위 폴더를 가져오고 페이지네이션으로 폴더를 검색하는 방법을 보여줍니다.
WebDav 사용
다음 코드 스니펫은 Exchange Server에서 폴더를 나열하는 방법을 보여줍니다.
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);
}
}