Validating attachments with javamail without receiving message content

I tried to find some answer or even a hint on how to do this, but no luck.

I want to check if there are any attachments in the email messages. But if I use the suggested code:

Object content = bPart.getContent();

if (content instanceof String) {
    if (Part.ATTACHMENT.equalsIgnoreCase(bPart.getDisposition()) || StringUtils.isNotBlank(bPart.getFileName())) {
        // It attachment
        haveAttachment = true;
    }
    else {
        // It text or html
        emailBody = content.toString();
    }
}
else if (content instanceof InputStream) {
    if (Part.ATTACHMENT.equalsIgnoreCase(bPart.getDisposition()) || StringUtils.isNotBlank(bPart.getFileName())) {
        // It attachment
        haveAttachment = true;
    }
}

I have to use the getContent () function in my email message, and the message is automatically marked as SEEN (read) on the server.

- , , , ? , , , getContent(), .

? , , .

!

: , getContent() SEEN?

+4
1

, "" , , , - JavaMail.

FAQ JavaMail.

MIME , isMimeType. msgshow.java .

+2

All Articles