IMAP을 사용한 메시지 첨부 파일 작업

IMAP 클라이언트를 사용한 메시지 첨부 파일 목록

첨부 파일의 이름, 크기와 같은 정보를 가져오되 첨부 데이터 자체를 가져오지 않으려면 다음 API 기능을 사용하십시오:

다음 코드 예제는 IMAP 클라이언트를 사용하여 서버에서 이메일 메시지 및 해당 첨부 파일에 대한 정보를 검색하고 각 메시지에 대한 첨부 파일 세부 정보를 표시하는 방법을 보여줍니다. 이를 통해 IMAP 프로토콜을 사용하여 이메일 메시지의 첨부 파일에 접근하고 처리할 수 있습니다.

ImapMessageInfoCollection messageInfoCollection = imapClient.listMessages();

for (ImapMessageInfo message : messageInfoCollection) {
    ImapAttachmentInfoCollection attachmentInfoCollection =
            imapClient.listAttachments(message.getSequenceNumber());

    for (ImapAttachmentInfo attachmentInfo : attachmentInfoCollection) {
        System.out.println(
                "Attachment: " + attachmentInfo.getName() + " (size: " + attachmentInfo.getSize() + ")");
    }
}