alfresco - 如何将文件附加到电子邮件?露天
问题描述
如何将文件(例如,工作流 packageItems 文件)附加到电子邮件?我尝试使用此代码,但未附加文件。我究竟做错了什么?如何将文件附加到电子邮件?
1.发送电子邮件委托
/*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
解决方案
您需要使用您自己的代码覆盖 Existing MailActionExecuter 类,其中附件将起作用。
覆盖 Bean:
<bean id="custom-mail" class="org.alfresco.MailActionExecuterWithAttachments" parent="action-executer">
......
</bean>
推荐阅读
- sql - 在 SQL 中运行 Sum 查询时苦苦挣扎
- django - Django 本地库项目
- javascript - JavaScript中的两个不同数组并组合单个数组
- c - 从另一个文件读取输入到 ac 程序时出错
- assembly - MOVZX r32, r/m16 和 MOVZX r64, r/m16 在 64 位 x86 中的区别
- python-3.x - 如何将正则表达式结果写入 CSV?
- c# - C# - 从浏览器获取 URL
- amazon-web-services - 通过 LastModified 在 AWS S3 中搜索文件
- sql-server - 如何使用 Informatica 在 Pre-SQL 中调用未连接的存储过程?
- python - 使用 Python 进行网页抓取:ConnectionError: HTTPSConnectionPool(host='towardsdatascience.com', port=443): Max retries exceeded with url