boolean convertMime = session.isConvertMime();
session.setConvertMIME(false);
try {
MIMEEntity topRelated = doc.createMIMEEntity("Body"); //$NON-NLS-1$
// Set up the multipart header
MIMEHeader header = topRelated.createHeader("Content-Type"); //$NON-NLS-1$
// EE needs to use multipart/alternative or the email clients will
// turn the content into an attachment.
header.setHeaderVal("multipart/related");
MIMEEntity topAlternative = topRelated.createChildEntity();
// Set up the multipart header
header = topAlternative.createHeader("Content-Type");
// EE needs to use multipart/alternative or the email clients will
// turn the content into an attachment.
header.setHeaderVal("multipart/alternative");
try {
for(MimePart part : getMimeParts()) {
MIMEEntity mime = topAlternative.createChildEntity();
try {
lotus.domino.Stream stream = session.createStream();
try {
String mimeType = part.getMimeType();
String content = part.getContent();
stream.writeText(content);
mime.setContentFromText(stream, mimeType, 0);
if(StringUtil.equals(mimeType, "text/plain")) {
mime.encodeContent(MIMEEntity.ENC_QUOTED_PRINTABLE);
} else {
mime.encodeContent(MIMEEntity.ENC_BASE64);
}
} finally {
stream.close();
stream.recycle();
}
} finally {
mime.recycle();
}
}