Hello everyone, I have been discovering node-red on a Pi for a few months without any notion of programming.
By helping me with the different forum posts, I managed to create a small process that allows me:
- to retrieve attachments from my mailbox
- to store them in a directory on my Pi.
However, I am unable to keep the name of the downloaded file. I think the problem is in the second change node where I unsuccessfully attempt to set msg.filename.
I have tried and retried a lot of solutions but nothing helps.
Could someone give me some directions?
Thank you in advance.
[{"id":"c128c243.3d8ca","type":"change","z":"a20d7f28.025a2","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"attachments","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":200,"y":180,"wires":[["6ef8cc1c.4b88e4","73cba29c.810c5c"]]},{"id":"6ef8cc1c.4b88e4","type":"split","z":"a20d7f28.025a2","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":370,"y":180,"wires":[["2a8396a0.bf301a","da5f185e.b7a3c8"]]},{"id":"d59830f4.bb3a8","type":"file","z":"a20d7f28.025a2","name":"Save picture to disk","filename":"","appendNewline":true,"createDir":true,"overwriteFile":"true","encoding":"none","x":1010,"y":180,"wires":[[]]},{"id":"83af9472.1aba98","type":"inject","z":"a20d7f28.025a2","name":"trigger email fetch","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":230,"y":80,"wires":[["16bcdf7c.2563f1"]]},{"id":"16bcdf7c.2563f1","type":"e-mail in","z":"a20d7f28.025a2","name":"Fetch Emails","protocol":"IMAP","server":"imap.gmail.com","useSSL":true,"port":"993","box":"","disposition":"Read","criteria":"UNSEEN","repeat":"300","fetch":"trigger","inputs":1,"x":510,"y":80,"wires":[["c128c243.3d8ca"]]},{"id":"73cba29c.810c5c","type":"debug","z":"a20d7f28.025a2","name":"set","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":150,"y":240,"wires":[]},{"id":"2a8396a0.bf301a","type":"debug","z":"a20d7f28.025a2","name":"split","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":350,"y":240,"wires":[]},{"id":"df95f50d.dc4548","type":"debug","z":"a20d7f28.025a2","name":"compose","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":610,"y":240,"wires":[]},{"id":"da5f185e.b7a3c8","type":"change","z":"a20d7f28.025a2","name":"compose filename and load content to payload","rules":[{"t":"set","p":"filename","pt":"msg","to":"/home/pi/.local/share/kiosque/ref/photos/{{filename}}","tot":"json"},{"t":"set","p":"payload","pt":"msg","to":"payload.content","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":660,"y":180,"wires":[["d59830f4.bb3a8","df95f50d.dc4548"]]}]