IMAP 사서함에서 폴더 정보 가져오기

Aspose.Email - IMAP 사서함에서 폴더 정보 가져오기

Aspose.Email을 사용하면 IMAP 서버에서 폴더 정보를 가져오는 것이 매우 쉽습니다. ImapClient의 listFolders() 메서드는 서버의 모든 폴더에 대한 정보를 포함하는 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());

}

실행 코드 다운로드

다음에 언급된 소셜 코딩 사이트 중 어디서든 IMAP 사서함에서 폴더 정보 가져오기를 다운로드하십시오: