Attach pdf with email
Hi,
We are trying to send a pdf attachment ( the file is stored in dam ) . The below mentioned code is used to read the file from DAM.
String fileName = "/content/dam/pdfs/retail/test.pdf";
resource = resolver.getResource(fileName);
Node imageNode = resource.adaptTo(Node.class);
Node contentNode = imageNode.getNode("jcr:content");
Binary contentBinary = contentNode.getProperty("jcr:data")
.getBinary();
InputStream pStredfam = contentBinary .getStream()
-----------------------------------------------------------------------------------------
ByteArrayDataSource pdfDS = new ByteArrayDataSource(pdfStream,"application/pdf");
email.attach(pdfDS,"Some test","Some test");
---------------------------------------------------------------------------------------------------------------------------------
However , getting an error saying that "jcr:data" not found.
javax.jcr.PathNotFoundException: jcr:data not found on /content/dam/pdfs/retail/test.pdf/jcr:content
Can you please suggest what is the right way to do the same ?