1
0
Fork 0
mirror of https://github.com/M66B/FairEmail.git synced 2024-12-27 02:07:12 +00:00

Simplication

This commit is contained in:
M66B 2019-11-30 18:41:24 +01:00
parent e6ac85b7be
commit 1a273ca083

View file

@ -395,6 +395,11 @@ public class MessageHelper {
BodyPart plainPart = new MimeBodyPart();
plainPart.setContent(plainContent, "text/plain; charset=" + Charset.defaultCharset().name());
if (message.plain_only != null && message.plain_only) {
imessage.setContent(plainContent, plainPart.getContentType());
return;
}
BodyPart htmlPart = new MimeBodyPart();
htmlPart.setContent(htmlContent, "text/html; charset=" + Charset.defaultCharset().name());
@ -402,8 +407,6 @@ public class MessageHelper {
altMultiPart.addBodyPart(plainPart);
altMultiPart.addBodyPart(htmlPart);
boolean plain_only = (message.plain_only != null && message.plain_only);
int availableAttachments = 0;
boolean hasInline = false;
for (EntityAttachment attachment : attachments)
@ -414,21 +417,15 @@ public class MessageHelper {
}
if (availableAttachments == 0)
if (plain_only)
imessage.setContent(plainContent, "text/plain; charset=" + Charset.defaultCharset().name());
else
imessage.setContent(altMultiPart);
imessage.setContent(altMultiPart);
else {
Multipart mixedMultiPart = new MimeMultipart("mixed");
Multipart relatedMultiPart = new MimeMultipart("related");
BodyPart bodyPart = new MimeBodyPart();
if (plain_only)
bodyPart.setContent(plainContent, "text/plain; charset=" + Charset.defaultCharset().name());
else
bodyPart.setContent(altMultiPart);
bodyPart.setContent(altMultiPart);
if (hasInline && !plain_only) {
if (hasInline) {
relatedMultiPart.addBodyPart(bodyPart);
MimeBodyPart relatedPart = new MimeBodyPart();
relatedPart.setContent(relatedMultiPart);
@ -476,7 +473,7 @@ public class MessageHelper {
if (attachment.cid != null)
attachmentPart.setHeader("Content-ID", attachment.cid);
if (attachment.isInline() && !plain_only)
if (attachment.isInline())
relatedMultiPart.addBodyPart(attachmentPart);
else
mixedMultiPart.addBodyPart(attachmentPart);