Alfresco unterstützt Mail-Anhänge nicht sofort.
Sie können die MailActionExecuter-Klasse bearbeiten und einen Parameter für Anlagen hinzufügen und diese dann als mimemultipart-Nachricht hinzufügen. etwa so:
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);
können Sie die mailAction wie folgt verwenden:
ActionService actionService = serviceRegistry.getActionService();
Action mailAction = actionService.createAction(MailActionExecuter.NAME);
mailAction.setParameterValue(MailActionExecuter.PARAM_TO , "[email protected]");
List<NodeRef> attachements = new ArrayList<>();
//TODOD add noderefs to attachements list...
mailAction.setParameterValue(MailActionExecuter.PARAM_ATTACHMENTS, attachements);
actionService.executeAction(mailAction, null);
Ist es normal, dass mail.parameters.text tut ein endgültiges Angebot haben? => 'Hallo $ {trainerer panelement_trainername}, \ n \ – Akah
ja, das ist das letzte Zitat, mein Problem ist nicht Anhänge anhängen – Paul