Hello,
can someone help me to optimize my code ? I want to send CSV files by email, at the moment I solve this with a join node, is there also a way to send it without join node?
I have added my code.
[{"id":"e56d7627.05dcc8","type":"e-mail","z":"95c84ff6.b3002","server":"smtp.gmail.com","port":"465","secure":true,"tls":true,"name":"recipient@mail.com","dname":"","x":950,"y":1500,"wires":[]},{"id":"b2f0df20.8ae7","type":"inject","z":"95c84ff6.b3002","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"str","x":200,"y":1500,"wires":[["5acda1ca.3d834"]]},{"id":"5acda1ca.3d834","type":"file in","z":"95c84ff6.b3002","name":"","filename":"E:\\NEU.csv","format":"","chunk":false,"sendError":false,"encoding":"none","x":390,"y":1500,"wires":[["2c026326.9e133c"]]},{"id":"2c026326.9e133c","type":"join","z":"95c84ff6.b3002","name":"","mode":"custom","build":"array","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"1","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":570,"y":1500,"wires":[["66fac98b.2142c8"]]},{"id":"66fac98b.2142c8","type":"function","z":"95c84ff6.b3002","name":"Prepare Email","func":"// Get the current time and convert it to text\nvar now = new Date();\nvar yyyy = now.getFullYear();\nvar mm = now.getMonth() < 9 ? \"0\" + (now.getMonth() + 1) : (now.getMonth() + 1); // getMonth() is zero-based\nvar dd = now.getDate() < 10 ? \"0\" + now.getDate() : now.getDate();\nvar hh = now.getHours() < 10 ? \"0\" + now.getHours() : now.getHours();\nvar mmm = now.getMinutes() < 10 ? \"0\" + now.getMinutes() : now.getMinutes();\nvar ss = now.getSeconds() < 10 ? \"0\" + now.getSeconds() : now.getSeconds();\n\n//Filegenerator\nvar data = \"Wasseraufbereitungsanlage_\"+dd+\"_\"+mm+\"_\"+yyyy+\".csv\";\n\n\nmsg.attachments = [{filename: data, content: msg.payload[0]}];\n\n\nmsg.payload = \"Email Body Message\";\n\nmsg.topic = \"Subject Message\";\n\n\n\n\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":740,"y":1500,"wires":[["e56d7627.05dcc8"]]}]