How to read Email Body in HTML format?

Confluence User - 19 Aug, 2022

Problem:

I am using email pool to read the email the data I am receiving is in multipart or in text format the code which I am using is here.

 if (message.getContent() instanceof Multipart) {
                    Multipart multipart = (Multipart)message.getContent();
                    for (int j = 0; j < multipart.getCount(); j++) {
                        BodyPart bodyPart = multipart.getBodyPart(j);
                        String disposition = bodyPart.getDisposition();
                        if (disposition != null && (disposition.equalsIgnoreCase("ATTACHMENT"))) { // BodyPart.ATTACHMENT doesn't work for gmail
                            debug("Attachment found");
                        } else {
                            content= bodyPart.getContent().toString();
                            break;
                        }
                    }
                } else {
                    content = message.getContent().toString();
                }

Outpout:

1.Simple Text

2. Mime Multipart



Requirement:

Read the email body in html format so it will be good to read

so please suggest me how can I read the body content in html format istead of text or multipart


java;email;all

2


19 Aug, 2022
confluenceUser
confluenceUser
19 Aug, 2022
confluenceUser
confluenceUser

Mime type is Multipart I want exact html format as it is sent to me

RELATED QUESTIONS

Your answer


To answer a question you'll need an account.

Print