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 { ...@@ -1454,11 +1454,18 @@ public class MailManagerImpl implements MailManager, InitializingBean {
if (attachments != null && !attachments.isEmpty()) { if (attachments != null && !attachments.isEmpty()) {
// with attachment use multipart message // with attachment use multipart message
Multipart multipart = new MimeMultipart(); Multipart multipart = new MimeMultipart("mixed");
// 1) add body part // 1) add body part
BodyPart messageBodyPart = new MimeBodyPart(); if(StringHelper.isHtml(body)) {
messageBodyPart.setText(body); Multipart alternativePart = createMultipartAlternative(body);
multipart.addBodyPart(messageBodyPart); MimeBodyPart wrap = new MimeBodyPart();
wrap.setContent(alternativePart);
multipart.addBodyPart(wrap);
} else {
BodyPart messageBodyPart = new MimeBodyPart();
messageBodyPart.setText(body);
multipart.addBodyPart(messageBodyPart);
}
// 2) add attachments // 2) add attachments
for (DBMailAttachment attachment : attachments) { for (DBMailAttachment attachment : attachments) {
// abort if attachment does not exist // abort if attachment does not exist
...@@ -1468,7 +1475,7 @@ public class MailManagerImpl implements MailManager, InitializingBean { ...@@ -1468,7 +1475,7 @@ public class MailManagerImpl implements MailManager, InitializingBean {
+ (attachment == null ? null : attachment.getName()), null); + (attachment == null ? null : attachment.getName()), null);
return msg; return msg;
} }
messageBodyPart = new MimeBodyPart(); BodyPart messageBodyPart = new MimeBodyPart();
VFSLeaf data = getAttachmentDatas(attachment); VFSLeaf data = getAttachmentDatas(attachment);
DataSource source = new VFSDataSource(attachment.getName(), attachment.getMimetype(), data); DataSource source = new VFSDataSource(attachment.getName(), attachment.getMimetype(), data);
...@@ -1480,7 +1487,11 @@ public class MailManagerImpl implements MailManager, InitializingBean { ...@@ -1480,7 +1487,11 @@ public class MailManagerImpl implements MailManager, InitializingBean {
msg.setContent(multipart); msg.setContent(multipart);
} else { } else {
// without attachment everything is easy, just set as text // 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.setSentDate(new Date());
msg.saveChanges(); 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