我正在使用alfresco社区版-5.1.x,我已经配置了附件无法正常工作的电子邮件通知,
var mail = actions.create('mail');
mail.parameters.to='${bmp_traineremail}';
mail.parameters.cc='';
mail.parameters.from='xxx@gmail.com';
mail.parameters.node=bpm_package.children[0];
mail.parameters.subject='Congrats ${bmp_trainername}';
mail.parameters.text='Hello ${trainerempanelment_trainername},\n\
mail.execute(bpm_package);
请帮帮我。
答案 0 :(得分:1)
Alfresco不支持开箱即用的邮件附件。
您可能希望编辑MailActionExecuter类并为附件添加参数,然后将这些参数添加为mimemultipart消息。像这样:
public static final String PARAM_ATTACHMENTS = "attachments";
public void prepare(MimeMessage mimeMessage) throws MessagingException{
...
MimeMultipart content = new MimeMultipart("mixed");
MimeBodyPart textPart = new MimeBodyPart();
if (isHTML){
textPart.setContent(text, "text/html; charset=utf-8");
} else {
textPart.setText(text);
}
content.addBodyPart(textPart);
List<NodeRef> attachments = (List<NodeRef>) ruleAction.getParameterValue(PARAM_ATTACHMENTS);
if (attachments != null){
for (final NodeRef attachnode : attachments){
MimeBodyPart attachment = new MimeBodyPart();
final String filename = nodeService.getProperty(attachnode, ContentModel.PROP_NAME).toString();
attachment.setFileName(filename);
attachment.setDataHandler(new DataHandler(new DataSource() {
public InputStream getInputStream() throws IOException {
return serviceRegistry.getContentService().getReader(attachnode, ContentModel.PROP_CONTENT).getContentInputStream();
}
public OutputStream getOutputStream() throws IOException {
throw new IOException("Read-only data");
}
public String getContentType() {
return serviceRegistry.getContentService().getReader(attachnode, ContentModel.PROP_CONTENT).getMimetype();
}
public String getName() {
return filename;
}
}));
content.addBodyPart(attachment);
}
}
mimeMessage.setContent(content);
您可以像这样使用mailAction:
ActionService actionService = serviceRegistry.getActionService();
Action mailAction = actionService.createAction(MailActionExecuter.NAME);
mailAction.setParameterValue(MailActionExecuter.PARAM_TO , "me@gmail.com" );
List<NodeRef> attachements = new ArrayList<>();
//TODOD add noderefs to attachements list...
mailAction.setParameterValue(MailActionExecuter.PARAM_ATTACHMENTS, attachements );
actionService.executeAction(mailAction, null);