Commit 352ddead authored by Thomas Huster's avatar Thomas Huster

[17773] added mail account id parameter to send mail no ui command

parent 43cc5a6f
Pipeline #12672 passed with stages
in 5 minutes
......@@ -39,10 +39,10 @@
<command
defaultHandler="ch.elexis.core.mail.ui.handlers.SendMailNoUiHandler"
id="ch.elexis.core.mail.ui.sendMailNoUi"
name="Send E-Mail">
name="Send E-Mail no UI">
<commandParameter
id="ch.elexis.core.mail.ui.sendMailNoUi.mandant"
name="text"
name="mandant"
optional="true">
</commandParameter>
<commandParameter
......@@ -65,6 +65,11 @@
name="text"
optional="true">
</commandParameter>
<commandParameter
id="ch.elexis.core.mail.ui.sendMailNoUi.accountid"
name="accountid"
optional="true">
</commandParameter>
</command>
</extension>
<extension
......
......@@ -21,6 +21,7 @@ import ch.elexis.data.Mandant;
* Handler for sending an Email without UI. The command execution returns a String with the result
* of sending the mail, which is empty on success. The mail can be specified via the command
* parameters.
* <li>ch.elexis.core.mail.ui.sendMailNoUi.accountid</li>
* <li>ch.elexis.core.mail.ui.sendMailNoUi.mandant</li>
* <li>ch.elexis.core.mail.ui.sendMailNoUi.attachments</li>
* <li>ch.elexis.core.mail.ui.sendMailNoUi.to</li>
......@@ -35,13 +36,19 @@ public class SendMailNoUiHandler extends AbstractHandler implements IHandler {
@Override
public Object execute(ExecutionEvent event) throws ExecutionException{
MailAccount mailAccount =
getMailAccount(event.getParameter("ch.elexis.core.mail.ui.sendMailNoUi.mandant"));
MailAccount mailAccount = null;
String accountId = event.getParameter("ch.elexis.core.mail.ui.sendMailNoUi.accountid");
if (StringUtils.isNoneBlank(accountId)) {
mailAccount = MailClientComponent.getMailClient().getAccount(accountId).orElse(null);
}
if (mailAccount == null) {
Mandant mandant =
Mandant.load(event.getParameter("ch.elexis.core.mail.ui.sendMailNoUi.mandant"));
return "No account for mandant ["
+ mandant.getLabel(false) + "]";
mailAccount =
getMailAccount(event.getParameter("ch.elexis.core.mail.ui.sendMailNoUi.mandant"));
if (mailAccount == null) {
Mandant mandant =
Mandant.load(event.getParameter("ch.elexis.core.mail.ui.sendMailNoUi.mandant"));
return "No account for mandant [" + mandant.getLabel(false) + "]";
}
}
String attachments = event.getParameter("ch.elexis.core.mail.ui.sendMailNoUi.attachments");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment