Skip to content

Commit

Permalink
option to specify pre-signature and post-signature body for emails. c…
Browse files Browse the repository at this point in the history
…lose #2590
  • Loading branch information
j-dimension committed Nov 26, 2024
1 parent 378ba44 commit ddf9669
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -805,7 +805,7 @@ public boolean execute() throws Exception {
SendEmailDialog dlg = new SendEmailDialog(false, EditorsRegistry.getInstance().getMainWindow(), false);
// make share link available for use via placeholder {{CLOUD_LINK}}
dlg.setCloudLink(share.getUrl());
dlg.setBody("Freigabelink: " + share.getUrl(), ContentTypes.TEXT_PLAIN);
dlg.setBody("Freigabelink: " + share.getUrl(), "", ContentTypes.TEXT_PLAIN);
if (caseDto != null) {
dlg.setArchiveFile(caseDto, null);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2169,11 +2169,11 @@ private void cmdForwardActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FI
String contentType = this.mailContentUI.getContentType();
dlg.setContentType(contentType);
if (contentType.toLowerCase().startsWith(ContentTypes.TEXT_HTML)) {
dlg.setBody(EmailUtils.getQuotedBody(EmailUtils.html2Text(this.mailContentUI.getBody()), ContentTypes.TEXT_PLAIN, decodedFrom, m.getSentDate()), ContentTypes.TEXT_PLAIN);
dlg.setBody("", EmailUtils.getQuotedBody(EmailUtils.html2Text(this.mailContentUI.getBody()), ContentTypes.TEXT_PLAIN, decodedFrom, m.getSentDate()), ContentTypes.TEXT_PLAIN);
} else {
dlg.setBody(EmailUtils.getQuotedBody(this.mailContentUI.getBody(), ContentTypes.TEXT_PLAIN, decodedFrom, m.getSentDate()), ContentTypes.TEXT_PLAIN);
dlg.setBody("", EmailUtils.getQuotedBody(this.mailContentUI.getBody(), ContentTypes.TEXT_PLAIN, decodedFrom, m.getSentDate()), ContentTypes.TEXT_PLAIN);
}
dlg.setBody(EmailUtils.getQuotedBody(this.mailContentUI.getBody(), ContentTypes.TEXT_HTML, decodedFrom, m.getSentDate()), ContentTypes.TEXT_HTML);
dlg.setBody("", EmailUtils.getQuotedBody(this.mailContentUI.getBody(), ContentTypes.TEXT_HTML, decodedFrom, m.getSentDate()), ContentTypes.TEXT_HTML);

try {
// try forwarding attachments
Expand Down Expand Up @@ -2272,11 +2272,11 @@ private void cmdReplyAllActionPerformed(java.awt.event.ActionEvent evt) {//GEN-F
String contentType = this.mailContentUI.getContentType();
dlg.setContentType(contentType);
if (contentType.toLowerCase().startsWith(ContentTypes.TEXT_HTML)) {
dlg.setBody(EmailUtils.getQuotedBody(EmailUtils.html2Text(this.mailContentUI.getBody()), ContentTypes.TEXT_PLAIN, decodedTo, origM.getSentDate()), ContentTypes.TEXT_PLAIN);
dlg.setBody("", EmailUtils.getQuotedBody(EmailUtils.html2Text(this.mailContentUI.getBody()), ContentTypes.TEXT_PLAIN, decodedTo, origM.getSentDate()), ContentTypes.TEXT_PLAIN);
} else {
dlg.setBody(EmailUtils.getQuotedBody(this.mailContentUI.getBody(), ContentTypes.TEXT_PLAIN, decodedTo, origM.getSentDate()), ContentTypes.TEXT_PLAIN);
dlg.setBody("", EmailUtils.getQuotedBody(this.mailContentUI.getBody(), ContentTypes.TEXT_PLAIN, decodedTo, origM.getSentDate()), ContentTypes.TEXT_PLAIN);
}
dlg.setBody(EmailUtils.getQuotedBody(this.mailContentUI.getBody(), ContentTypes.TEXT_HTML, decodedTo, origM.getSentDate()), ContentTypes.TEXT_HTML);
dlg.setBody("", EmailUtils.getQuotedBody(this.mailContentUI.getBody(), ContentTypes.TEXT_HTML, decodedTo, origM.getSentDate()), ContentTypes.TEXT_HTML);

} catch (Exception ex) {
log.error(ex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1274,11 +1274,11 @@ public static SendEmailDialog reply(OutlookMessage m, String prependContent, Str
prependContent=prependContent + System.lineSeparator() + System.lineSeparator();

if (contentType.toLowerCase().startsWith(ContentTypes.TEXT_HTML)) {
dlg.setBody(prependContent + EmailUtils.getQuotedBody(EmailUtils.html2Text(content), ContentTypes.TEXT_PLAIN, decodedTo, m.getDate()), ContentTypes.TEXT_PLAIN);
dlg.setBody(prependContent, EmailUtils.getQuotedBody(EmailUtils.html2Text(content), ContentTypes.TEXT_PLAIN, decodedTo, m.getDate()), ContentTypes.TEXT_PLAIN);
} else {
dlg.setBody(prependContent + EmailUtils.getQuotedBody(content, ContentTypes.TEXT_PLAIN, decodedTo, m.getDate()), ContentTypes.TEXT_PLAIN);
dlg.setBody(prependContent, EmailUtils.getQuotedBody(content, ContentTypes.TEXT_PLAIN, decodedTo, m.getDate()), ContentTypes.TEXT_PLAIN);
}
dlg.setBody(prependContent + EmailUtils.getQuotedBody(content, ContentTypes.TEXT_HTML, decodedTo, m.getDate()), ContentTypes.TEXT_HTML);
dlg.setBody(prependContent, EmailUtils.getQuotedBody(content, ContentTypes.TEXT_HTML, decodedTo, m.getDate()), ContentTypes.TEXT_HTML);

} catch (Exception ex) {
log.error(ex);
Expand Down Expand Up @@ -1358,11 +1358,11 @@ public static SendEmailDialog reply(Message m, String prependContent, String con
prependContent=prependContent + System.lineSeparator() + System.lineSeparator();

if (contentType.toLowerCase().startsWith(ContentTypes.TEXT_HTML)) {
dlg.setBody(prependContent + EmailUtils.getQuotedBody(EmailUtils.html2Text(content), ContentTypes.TEXT_PLAIN, decodedTo, m.getSentDate()), ContentTypes.TEXT_PLAIN);
dlg.setBody(prependContent, EmailUtils.getQuotedBody(EmailUtils.html2Text(content), ContentTypes.TEXT_PLAIN, decodedTo, m.getSentDate()), ContentTypes.TEXT_PLAIN);
} else {
dlg.setBody(prependContent + EmailUtils.getQuotedBody(content, ContentTypes.TEXT_PLAIN, decodedTo, m.getSentDate()), ContentTypes.TEXT_PLAIN);
dlg.setBody(prependContent, EmailUtils.getQuotedBody(content, ContentTypes.TEXT_PLAIN, decodedTo, m.getSentDate()), ContentTypes.TEXT_PLAIN);
}
dlg.setBody(prependContent + EmailUtils.getQuotedBody(content, ContentTypes.TEXT_HTML, decodedTo, m.getSentDate()), ContentTypes.TEXT_HTML);
dlg.setBody(prependContent, EmailUtils.getQuotedBody(content, ContentTypes.TEXT_HTML, decodedTo, m.getSentDate()), ContentTypes.TEXT_HTML);

} catch (Exception ex) {
log.error(ex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1187,12 +1187,12 @@ private MailboxSetup getSelectedMailbox() {
return null;
}

public void setBody(String b, String contentType) {
public void setBody(String preSignature, String postSignature, String contentType) {
MailboxSetup ms = this.getSelectedMailbox();

if (contentType.toLowerCase().startsWith(ContentTypes.TEXT_PLAIN)) {
if (ms != null) {
this.tp.setText(EmailUtils.html2Text(ms.getEmailSignature()) + b);
this.tp.setText(preSignature + EmailUtils.html2Text(ms.getEmailSignature()) + postSignature);
this.tp.setCaretPosition(0);
}
} else {
Expand All @@ -1201,7 +1201,7 @@ public void setBody(String b, String contentType) {
if (sig == null) {
sig = "";
}
this.hp.setText("<div>" + sig + "</div><br/><blockquote style=\"border-left: #ccc 0px solid; margin: 0px 0px 0px 0.8ex; padding-left: 1ex\">" + b + "</blockquote>");
this.hp.setText("<div>" + preSignature + "</div><div>" + sig + "</div><br/><blockquote style=\"border-left: #ccc 0px solid; margin: 0px 0px 0px 0.8ex; padding-left: 1ex\">" + postSignature + "</blockquote>");
this.hp.setCaretPosition(0);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -902,11 +902,11 @@ private void cmdReplyAllActionPerformed(java.awt.event.ActionEvent evt) {//GEN-F
String contentType = this.content.getContentType();
dlg.setContentType(contentType);
if (contentType.toLowerCase().startsWith(ContentTypes.TEXT_HTML)) {
dlg.setBody(EmailUtils.getQuotedBody(EmailUtils.html2Text(this.content.getBody()), ContentTypes.TEXT_PLAIN, decodedTo, origM.getSentDate()), ContentTypes.TEXT_PLAIN);
dlg.setBody("", EmailUtils.getQuotedBody(EmailUtils.html2Text(this.content.getBody()), ContentTypes.TEXT_PLAIN, decodedTo, origM.getSentDate()), ContentTypes.TEXT_PLAIN);
} else {
dlg.setBody(EmailUtils.getQuotedBody(this.content.getBody(), ContentTypes.TEXT_PLAIN, decodedTo, origM.getSentDate()), ContentTypes.TEXT_PLAIN);
dlg.setBody("", EmailUtils.getQuotedBody(this.content.getBody(), ContentTypes.TEXT_PLAIN, decodedTo, origM.getSentDate()), ContentTypes.TEXT_PLAIN);
}
dlg.setBody(EmailUtils.getQuotedBody(this.content.getBody(), ContentTypes.TEXT_HTML, decodedTo, origM.getSentDate()), ContentTypes.TEXT_HTML);
dlg.setBody("", EmailUtils.getQuotedBody(this.content.getBody(), ContentTypes.TEXT_HTML, decodedTo, origM.getSentDate()), ContentTypes.TEXT_HTML);

} catch (Exception ex) {
log.error(ex);
Expand All @@ -931,11 +931,11 @@ private void cmdReplyAllActionPerformed(java.awt.event.ActionEvent evt) {//GEN-F
String contentType = this.content.getContentType();
dlg.setContentType(contentType);
if (contentType.toLowerCase().startsWith(ContentTypes.TEXT_HTML)) {
dlg.setBody(EmailUtils.getQuotedBody(EmailUtils.html2Text(this.content.getBody()), ContentTypes.TEXT_PLAIN, decodedTo, this.outlookMsg.getDate()), ContentTypes.TEXT_PLAIN);
dlg.setBody("", EmailUtils.getQuotedBody(EmailUtils.html2Text(this.content.getBody()), ContentTypes.TEXT_PLAIN, decodedTo, this.outlookMsg.getDate()), ContentTypes.TEXT_PLAIN);
} else {
dlg.setBody(EmailUtils.getQuotedBody(this.content.getBody(), ContentTypes.TEXT_PLAIN, decodedTo, this.outlookMsg.getDate()), ContentTypes.TEXT_PLAIN);
dlg.setBody("", EmailUtils.getQuotedBody(this.content.getBody(), ContentTypes.TEXT_PLAIN, decodedTo, this.outlookMsg.getDate()), ContentTypes.TEXT_PLAIN);
}
dlg.setBody(EmailUtils.getQuotedBody(this.content.getBody(), ContentTypes.TEXT_HTML, decodedTo, this.outlookMsg.getDate()), ContentTypes.TEXT_HTML);
dlg.setBody("", EmailUtils.getQuotedBody(this.content.getBody(), ContentTypes.TEXT_HTML, decodedTo, this.outlookMsg.getDate()), ContentTypes.TEXT_HTML);

} catch (Exception ex) {
log.error(ex);
Expand Down Expand Up @@ -1002,11 +1002,11 @@ private void cmdForwardActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FI
String contentType = this.content.getContentType();
dlg.setContentType(contentType);
if (contentType.toLowerCase().startsWith(ContentTypes.TEXT_HTML)) {
dlg.setBody(EmailUtils.getQuotedBody(EmailUtils.html2Text(this.content.getBody()), ContentTypes.TEXT_PLAIN, decodedFrom, m.getSentDate()), ContentTypes.TEXT_PLAIN);
dlg.setBody("", EmailUtils.getQuotedBody(EmailUtils.html2Text(this.content.getBody()), ContentTypes.TEXT_PLAIN, decodedFrom, m.getSentDate()), ContentTypes.TEXT_PLAIN);
} else {
dlg.setBody(EmailUtils.getQuotedBody(this.content.getBody(), ContentTypes.TEXT_PLAIN, decodedFrom, m.getSentDate()), ContentTypes.TEXT_PLAIN);
dlg.setBody("", EmailUtils.getQuotedBody(this.content.getBody(), ContentTypes.TEXT_PLAIN, decodedFrom, m.getSentDate()), ContentTypes.TEXT_PLAIN);
}
dlg.setBody(EmailUtils.getQuotedBody(this.content.getBody(), ContentTypes.TEXT_HTML, decodedFrom, m.getSentDate()), ContentTypes.TEXT_HTML);
dlg.setBody("", EmailUtils.getQuotedBody(this.content.getBody(), ContentTypes.TEXT_HTML, decodedFrom, m.getSentDate()), ContentTypes.TEXT_HTML);

try {
// try forwarding attachments
Expand Down Expand Up @@ -1058,11 +1058,11 @@ private void cmdForwardActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FI
String contentType = this.content.getContentType();
dlg.setContentType(contentType);
if (contentType.toLowerCase().startsWith(ContentTypes.TEXT_HTML)) {
dlg.setBody(EmailUtils.getQuotedBody(EmailUtils.html2Text(this.content.getBody()), ContentTypes.TEXT_PLAIN, from, this.outlookMsg.getDate()), ContentTypes.TEXT_PLAIN);
dlg.setBody("", EmailUtils.getQuotedBody(EmailUtils.html2Text(this.content.getBody()), ContentTypes.TEXT_PLAIN, from, this.outlookMsg.getDate()), ContentTypes.TEXT_PLAIN);
} else {
dlg.setBody(EmailUtils.getQuotedBody(this.content.getBody(), ContentTypes.TEXT_PLAIN, from, this.outlookMsg.getDate()), ContentTypes.TEXT_PLAIN);
dlg.setBody("", EmailUtils.getQuotedBody(this.content.getBody(), ContentTypes.TEXT_PLAIN, from, this.outlookMsg.getDate()), ContentTypes.TEXT_PLAIN);
}
dlg.setBody(EmailUtils.getQuotedBody(this.content.getBody(), ContentTypes.TEXT_HTML, from, this.outlookMsg.getDate()), ContentTypes.TEXT_HTML);
dlg.setBody("", EmailUtils.getQuotedBody(this.content.getBody(), ContentTypes.TEXT_HTML, from, this.outlookMsg.getDate()), ContentTypes.TEXT_HTML);

try {
List<OutlookFileAttachment> attachments = this.outlookMsg.fetchTrueAttachments();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1119,7 +1119,7 @@ private void cmdSendActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST
dlg.addAttachment(tmpUrl, "");
dlg.setSubject("j-lawyer - Systeminformationen");
SimpleDateFormat df2 = new SimpleDateFormat("dd.MM.yyyy HH:mm");
dlg.setBody("Systembericht vom " + df2.format(new Date()), "text/plain");
dlg.setBody("Systembericht vom " + df2.format(new Date()), "", "text/plain");

FrameUtils.centerDialog(dlg, null);
dlg.setVisible(true);
Expand Down

0 comments on commit ddf9669

Please sign in to comment.