AnsweredAssumed Answered

How send email document attachment using workflow service task

Question asked by pnature on Jan 25, 2017
Latest reply on Feb 16, 2017 by pnature

Hi,

I am new on Alfresco community version 5.2 

I need send email when new document is uploaded in folder and attach it to the email.

I found some approaches but I cannot use any of them.

I created rule and script like this

https://community.alfresco.com/message/677786-re-attach-a-document-into-an-email?commentID=677786#comment-677786?q=How%2… 

Next I have tried start workflow by script and send email using service task (JavaDelegateClass) but there is problem get document

1) I have to set document as parameter in script

         workflow.parameters.docnode = document;

2) in java service task (JavaDelegateClass) 

         ActivitiScriptNode scriptNode = (ActivitiScriptNode) execution.getVariable("docnode");

         NodeRef docref = scriptNode.getNodeRef();

         ContentReader reader = contentService.getReader(docref, ContentModel.PROP_CONTENT);
         InputStream originalInputStream = reader.getContentInputStream();

         messageBodyPart = new MimeBodyPart(originalInputStream);

but contentService.getReader(docref, ContentModel.PROP_CONTENT) causes an exception

Caused by: java.lang.NullPointerException

docref = workspace://SpacesStore/c20bd21d-90d3-497f-9e0a-28951649116e

I search docref in node browser and

00300000 Node workspace://SpacesStore/c20bd21d-90d3-497f-9e0a-28951649116e does not exist.

What is the problem?

Help me please how can JavaDelegateClass access to document in workflow.

 

Thanks in advance.

Outcomes