Как прикрепить файлы (например, файлы packageItems рабочего процесса) к электронному письму? Я пытался использовать этот код, но файлы не прикрепляются. Что я делаю не так? Как прикрепить файл к электронному письму?
1.SendEmailDelegate
/*MailWithAttachmentActionExecuter*/
ActionService actionService = getServiceRegistry().getActionService();
Action mailAction = actionService.createAction(MailWithAttachmentActionExecuter.NAME);
mailAction.setParameterValue(MailWithAttachmentActionExecuter.PARAM_SUBJECT, SendEmailDelegate.SUBJECT);
mailAction.setParameterValue(MailWithAttachmentActionExecuter.PARAM_TO_MANY, recipients);
mailAction.setParameterValue(MailWithAttachmentActionExecuter.PARAM_FROM, SendEmailDelegate.FROM_ADDRESS);
mailAction.setParameterValue(MailWithAttachmentActionExecuter.PARAM_TEXT, sb.toString());
List<NodeRef> attachements = new ArrayList<>();
NodeRef workflowPackage = ((ActivitiScriptNode) task.getVariables().get("bpm_package")).getNodeRef();
//TODOD add noderefs to attachements list...
if (workflowPackage != null) {
NodeService nodeService = getServiceRegistry().getNodeService();
List<ChildAssociationRef> assocs = nodeService.getChildAssocs(workflowPackage);
NodeRef[] docs = new NodeRef[assocs.size()];
if (assocs.size() != 0) {
int index = 0;
for (ChildAssociationRef assoc : assocs) {
docs[index] = assoc.getChildRef();
attachements.add(assoc.getChildRef());
index++;
getServiceRegistry().getPermissionService().setInheritParentPermissions(assoc.getChildRef(), false);
getServiceRegistry().getPermissionService().setPermission(assoc.getChildRef(), PermissionService.ALL_AUTHORITIES, PermissionService.CONSUMER, true);
getServiceRegistry().getPermissionService().setInheritParentPermissions(assoc.getChildRef(), true);
}
}
mailAction.setParameterValue(MailWithAttachmentActionExecuter.PARAM_ATTACHMENTS, docs);
}
mailAction.setParameterValue(MailWithAttachmentActionExecuter.PARAM_SUBJECT, SendEmailDelegate.SUBJECT);
mailAction.setParameterValue(MailWithAttachmentActionExecuter.PARAM_TEXT, sb.toString());
//actionService.executeAction(mailAction, null);
actionService.executeAction(mailAction, null, false, sendEmailAsynchronously);
logger.debug("MailWithAttachmentActionExecuter executed");
<сильный>2. MailWithAttachmentActionExecuter MailWithAttachmentActionExecuter
MimeMessage
- никаких дополнительных параметров в коде, который вы можно установить по умолчанию - person Gagravarr   schedule 21.05.2020ERROR [repo.action.AsynchronousActionExecutionQueueImpl] [defaultAsyncAction2] Failed to execute asynchronous action: Action[ id=7bcde69f-214b-4f61-b76a-100454c36e5a, node=null ] java.lang.NullPointerException at CustomMailActionExecuter.java:1345, CustomMailActionExecuter.java:1171,CustomMailActionExecuter.java:544,CustomMailActionExecuter.java:482
Извините, не могли бы вы помочь мне подробнее? - person GEJ   schedule 09.06.2020