Skip to content
Snippets Groups Projects
Commit 3b1ee915 authored by srosse's avatar srosse
Browse files

OO-2972: send the forward with html content with a multi part email

parent 38ce7ca5
No related branches found
No related tags found
No related merge requests found
......@@ -1454,11 +1454,18 @@ public class MailManagerImpl implements MailManager, InitializingBean {
if (attachments != null && !attachments.isEmpty()) {
// with attachment use multipart message
Multipart multipart = new MimeMultipart();
Multipart multipart = new MimeMultipart("mixed");
// 1) add body part
BodyPart messageBodyPart = new MimeBodyPart();
messageBodyPart.setText(body);
multipart.addBodyPart(messageBodyPart);
if(StringHelper.isHtml(body)) {
Multipart alternativePart = createMultipartAlternative(body);
MimeBodyPart wrap = new MimeBodyPart();
wrap.setContent(alternativePart);
multipart.addBodyPart(wrap);
} else {
BodyPart messageBodyPart = new MimeBodyPart();
messageBodyPart.setText(body);
multipart.addBodyPart(messageBodyPart);
}
// 2) add attachments
for (DBMailAttachment attachment : attachments) {
// abort if attachment does not exist
......@@ -1468,7 +1475,7 @@ public class MailManagerImpl implements MailManager, InitializingBean {
+ (attachment == null ? null : attachment.getName()), null);
return msg;
}
messageBodyPart = new MimeBodyPart();
BodyPart messageBodyPart = new MimeBodyPart();
VFSLeaf data = getAttachmentDatas(attachment);
DataSource source = new VFSDataSource(attachment.getName(), attachment.getMimetype(), data);
......@@ -1480,7 +1487,11 @@ public class MailManagerImpl implements MailManager, InitializingBean {
msg.setContent(multipart);
} else {
// without attachment everything is easy, just set as text
msg.setText(body, "utf-8");
if(StringHelper.isHtml(body)) {
msg.setContent(createMultipartAlternative(body));
} else {
msg.setText(body, "utf-8");
}
}
msg.setSentDate(new Date());
msg.saveChanges();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment