HowTo send Email with local attachment

I have already read carefully in the forum and put together various building blocks. But I don't get an attachment at the end. The text is there, but the photo is missing. I think it's relatively easy and I like to learn. Maybe someone can help me?

[{"id":"dee99cab99266e8b","type":"file in","z":"49e813ed38cbfdd9","name":"Deepstack Foto Flur","filename":"/config/www/snapshots/deepstack/flur/deepstack_object_diskstation_flur_latest.jpg","format":"utf8","chunk":false,"sendError":false,"encoding":"none","allProps":false,"x":1960,"y":140,"wires":[["42d4baf4fae75719"]]},{"id":"58911bc8d4043075","type":"inject","z":"49e813ed38cbfdd9","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":1720,"y":140,"wires":[["dee99cab99266e8b"]]},{"id":"330af8200b4403a3","type":"debug","z":"49e813ed38cbfdd9","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":2610,"y":140,"wires":[]},{"id":"5e11ea515c3e05bb","type":"function","z":"49e813ed38cbfdd9","name":"write Email","func":"msg = {\n    topic: `Kamera Flur @ ${Date()}`,\n    payload: \"ACHTUNG - Einbruch TĂĽr Flur  \",\n    attachments: [{\n        \"filename\": \"deepstack_object_diskstation_flur_latest.jpg\",\n        \"content\": msg.payload,\n        \"encoding\": 'base64'\n     }]\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":2410,"y":140,"wires":[["330af8200b4403a3"]]},{"id":"42d4baf4fae75719","type":"change","z":"49e813ed38cbfdd9","name":"set attachment","rules":[{"t":"set","p":"attachments","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":2200,"y":140,"wires":[["5e11ea515c3e05bb"]]}]

Maybe it's even easier than I imagined - with fewer building blocks?

Try to change you File read node to Buffer
image

and remove the base64 encoding from attachments

Example:

[{"id":"dee99cab99266e8b","type":"file in","z":"5847b7aa62131d37","name":"Deepstack Foto Flur","filename":"C:\\share\\Test.png","format":"","chunk":false,"sendError":false,"encoding":"none","allProps":false,"x":380,"y":1300,"wires":[["5e11ea515c3e05bb"]]},{"id":"58911bc8d4043075","type":"inject","z":"5847b7aa62131d37","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":180,"y":1300,"wires":[["dee99cab99266e8b"]]},{"id":"330af8200b4403a3","type":"debug","z":"5847b7aa62131d37","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":750,"y":1300,"wires":[]},{"id":"5e11ea515c3e05bb","type":"function","z":"5847b7aa62131d37","name":"write Email","func":"let fileBuffer = msg.payload;\n\nmsg = {\n    topic: `Kamera Flur @ ${Date()}`,\n    payload: \"ACHTUNG - Einbruch TĂĽr Flur  \",\n    attachments: [{\n        \"filename\": \"deepstack_object_diskstation_flur_latest.jpg\",\n        \"content\": fileBuffer\n     }]\n}\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":590,"y":1300,"wires":[["330af8200b4403a3"]]}]
1 Like

Many many thanks. It works perfectly.
I would not have come across the entry with the FileBuffer so quickly. brilliant

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.