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.
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.