Hi guys,
I've a flow that generates a pdf and sends it as attachment via email.
I would like to put this file into a zip archive using node-red-contrib-zip (node) - Node-RED and send the Zip via email (in the future will be more then 1 pdf).
Do you know how can do it? Because I tried but with no success.
If you have an example or any doc I'm reale thankful.
Below the flow I use if it can be useful.
[{"id":"ac068b5c39f0e4a4","type":"template","z":"1917cb7f61a6fd19","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"<!DOCTYPE html>\n<html>\n<head>\n\t<title>Fattura</title> \n</head>\n<body>\n\tMY CONTENT\n</body>\n</html>","output":"str","x":360,"y":640,"wires":[["d1c14d2c2167243d"]]},{"id":"1730ae45f578c58e","type":"inject","z":"1917cb7f61a6fd19","name":"Test","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":210,"y":640,"wires":[["ac068b5c39f0e4a4"]]},{"id":"7d6c780e12468f5a","type":"e-mail","z":"1917cb7f61a6fd19","server":"mail.smtp.com","port":"465","secure":true,"tls":true,"name":"mail@domain.com","dname":"Send Email","x":1270,"y":640,"wires":[]},{"id":"d1c14d2c2167243d","type":"function","z":"1917cb7f61a6fd19","name":"HTML to docDef","func":"const { JSDOM } = jsdom;\nconst { window } = new JSDOM(\"\");\n\nconst html = htmlToPdfmake(msg.payload, { \n tableAutoSize:true, \n window: window\n});\n\nconst docDefinition = {\n // a string or { width: number, height: number }\n pageSize: msg.pageSize || 'A4',\n // by default we use portrait, you can change it to landscape if you wish\n pageOrientation: msg.pageOrientation || 'portrait',\n\n // [left, top, right, bottom] or [horizontal, vertical] or just a number for equal margins\n pageMargins: [40, 40, 40, 40],\n\n content: [\n html\n ],\n \n}\n\nmsg.filename = 'receipt.pdf'\n\nmsg.payload = docDefinition\n\nreturn msg","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[{"var":"htmlToPdfmake","module":"html-to-pdfmake"},{"var":"jsdom","module":"jsdom"}],"x":550,"y":640,"wires":[["9f9e45629034f036"]]},{"id":"9f9e45629034f036","type":"pdfmake","z":"1917cb7f61a6fd19","name":"","outputType":"Buffer","inputProperty":"payload","options":"{}","outputProperty":"payload","x":740,"y":640,"wires":[["d655251d175dd0fc"]]},{"id":"d655251d175dd0fc","type":"file","z":"1917cb7f61a6fd19","name":"","filename":"receipt.pdf","appendNewline":true,"createDir":false,"overwriteFile":"true","encoding":"none","x":910,"y":640,"wires":[["595d595c1ec44a20"]]},{"id":"595d595c1ec44a20","type":"function","z":"1917cb7f61a6fd19","name":"Set email","func":"msg.from = 'from@domain.com'\nmsg.topic = 'Email topic'\nmsg.payload = 'Email payload'\nmsg.attachments = [ { // use URL as an attachment\n filename: 'receipt.pdf',\n path: 'https://mydomain.com/receipt.pdf'\n}]\n \nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1080,"y":640,"wires":[["7d6c780e12468f5a"]]}]
Thanks in advance and kind regards,
Davide