Posted By:
Kevin_McMullen
Posted On:
Thursday, January 9, 2003 09:00 AM
I am making an e-mail application for work using javamail, and this client will be recieving multipart messages generated from outlook clients. displaying normal text e-mails works, and html messages from other clients such as sylpheed on linux works too, but i cannot successfully display the text/html part of an outlook generated e-mail. i can display the text/plain part fine. the html is being sent to a JEditorPane named bodyPane. messages[] is an array of Messages. here is what the body-displaying code looks like: public void displayMessageBody(int id) { try { Part messagePart = messages[id]; Object content = messagePart.getContent(); if (content instanceof Multipart) { Multipart multiPart = (
More>>
I am making an e-mail application for work using javamail, and this client will be recieving multipart messages generated from outlook clients. displaying normal text e-mails works, and html messages from other clients such as sylpheed on linux works too, but i cannot successfully display the text/html part of an outlook generated e-mail. i can display the text/plain part fine. the html is being sent to a JEditorPane named bodyPane. messages[] is an array of Messages. here is what the body-displaying code looks like:
public void displayMessageBody(int id) {
try {
Part messagePart = messages[id];
Object content = messagePart.getContent();
if (content instanceof Multipart) {
Multipart multiPart = (Multipart)messages[id].getContent();
BodyPart bodyPart = multiPart.getBodyPart(1);
bodyPane.setContentType(bodyPart.getContentType());
bodyPane.setText(bodyPart.getContent().toString());
}
else {
bodyPane.setContentType(messagePart.getContentType());
bodyPane.setText((String)messagePart.getContent());
}
} catch (Exception e) { e.printStackTrace(); }
}
i just use multiPar.getBodyPart(1) directly because i know that is the body part of type text/html (i verified it by printing both the mimetype and the content to the command line).
<<Less