Error payload in mail

Hello

I willed format a mail but my payload result isn't good.

result paylaod in debug node :

LIDL - MONTPELLIER : 17.35 Go
LIDL - LA GRANDE MOTTE : 0.4 Go
LIDL - LE CANNET : 2.06 Go
LIDL - CAGNES SUR MER : 2.23 Go
LIDL - LA TALAUDIERE : 1.46 Go
LIDL - MELUN : 8.01 Go
LIDL - VALLAURIS : 7.22 Go
LIDL - AUBERVILLIERS : 55.39 Go
LIDL - MEAUX LOGISTIQUE : 5.56 Go
LIDL - BOBIGNY : 8.51 Go
LIDL - LA ROCHE SUR FORON : 2.18 Go
LIDL - CHAMALIERES : 11.62 Go
LIDL - ISSOIRE : 9.13 Go
LIDL - NEVERS : 14.93 Go
LIDL - DAIX : 5.42 Go
LIDL - SAINT ETIENNE ROUSSEAU : 16.45 Go
LIDL - RIOM : 4.44 Go
LIDL - NICE GALLIENI : 5.26 Go
LIDL - VILLENEUVE LE ROI : 14.24 Go
LIDL - EVRY : 11.71 Go
BOX V3 - LIDL MARSEILLE SAINT MITRE : 44.29 Go
LIDL - BORDEAUX LE HAILLAN : 28.16 Go
LIDL - ROANNE : 18.9 Go
LIDL - SAVIGNEUX : 8.1 Go
LIDL - PONTOISE : 12.77 Go

but in my mail is :

Bonjour,
Voici la liste des sites ayant surconsommés sur le mois de 2023-07 :
LIDL - MONTPELLIER : 17.35 Go
LIDL - LA GRANDE MOTTE : 0.4 Go
LIDL - LE CANNET : 2.06 Go
LIDL - CAGNES SUR MER : 2.23 Go
LIDL - LA TALAUDIERE : 1.46 Go
LIDL - MELUN : 8.01 Go
LIDL - VALLAURIS : 7.22 Go
LIDL - AUBERVILLIERS : 55.39 Go
LIDL - MEAUX LOGISTIQUE : 5.56 Go
LIDL - BOBIGNY : 8.51 Go
LIDL - LA ROCHE SUR FORON : 2.18 Go
LIDL - CHAMALIERES : 11.62 Go
LIDL - ISSOIRE : 9.13 Go
LIDL - NEVERS : 14.93 Go
LIDL - DAIX : 5.42 Go
LIDL - SAINT ETIENNE ROUSSEAU : 16.45 Go LIDL - RIOM : 4.44 Go LIDL - NICE GALLIENI : 5.26 Go LIDL - VILLENEUVE LE ROI : 14.24 Go LIDL - EVRY : 11.71 Go BOX V3 - LIDL MARSEILLE SAINT MITRE : 44.29 Go LIDL - BORDEAUX LE HAILLAN : 28.16 Go LIDL - ROANNE : 18.9 Go LIDL - SAVIGNEUX : 8.1 Go LIDL - PONTOISE : 12.77 Go
Cordialement

Wher is the probleme ?

flow

[{"id":"b7517c4aec6c6215","type":"json","z":"be3c6730.befb08","name":"","property":"payload","action":"","pretty":false,"x":1250,"y":2100,"wires":[["6c244db27fdb7858"]]},{"id":"6c244db27fdb7858","type":"string","z":"be3c6730.befb08","name":"","methods":[{"name":"replaceAll","params":[{"type":"str","value":"{"},{"type":"str","value":""}]},{"name":"replaceAll","params":[{"type":"str","value":"}"},{"type":"str","value":""}]},{"name":"replaceAll","params":[{"type":"str","value":"\"reference\":\""},{"type":"str","value":""}]},{"name":"replaceAll","params":[{"type":"str","value":"\",\"data\":\""},{"type":"str","value":" : "}]},{"name":"replaceAll","params":[{"type":"str","value":"\""},{"type":"str","value":" Go"}]},{"name":"replaceAll","params":[{"type":"str","value":","},{"type":"str","value":"\\n"}]},{"name":"replaceAll","params":[{"type":"str","value":"["},{"type":"str","value":""}]},{"name":"replaceAll","params":[{"type":"str","value":"]"},{"type":"str","value":""}]}],"prop":"payload","propout":"payload","object":"msg","objectout":"msg","x":1370,"y":2100,"wires":[["d155fd3ab949fa9e","595c3b32829c8fa1"]]},{"id":"d155fd3ab949fa9e","type":"string","z":"be3c6730.befb08","name":"","methods":[{"name":"delRightMost","params":[{"type":"str","value":"-"}]}],"prop":"date","propout":"date","object":"msg","objectout":"msg","x":770,"y":2160,"wires":[["418a22028a4ca28f"]]},{"id":"418a22028a4ca28f","type":"change","z":"be3c6730.befb08","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"\"Export de la surconsommation du \"& $$.date","tot":"jsonata"},{"t":"move","p":"payload","pt":"msg","to":"liste","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":920,"y":2160,"wires":[["26b9f03148396193"]]},{"id":"26b9f03148396193","type":"template","z":"be3c6730.befb08","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"Bonjour,\n\nVoici la liste des sites ayant surconsommés sur le mois de {{date}}:\n{{liste}}\n\nCordialement","output":"str","x":1080,"y":2160,"wires":[["3ff0cc699ddc0384"]]},{"id":"595c3b32829c8fa1","type":"debug","z":"be3c6730.befb08","name":"debug 307","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1550,"y":2100,"wires":[]}]

Please add a debug node (set to display the complete msg object) to the output of the node feeding the json node. Then copy and paste the complete output to a reply so we can see what your data looks like. Without seeing the complete msg data there is no way to determine what is happening.


There’s a great page in the docs (Working with messages : Node-RED) that will explain how to use the debug panel to find the right path to any data item.

Pay particular attention to the part about the buttons that appear under your mouse pointer when you over hover a debug message property in the sidebar.

BX00Cy7yHi


In order to make code readable and usable it is necessary to surround your code with three backticks (also known as a left quote or backquote ```)

``` 
   code goes here 
```

You can edit and correct your post by clicking the pencil :pencil2: icon.

See this post for more details - How to share code or flow json

{"_msgid":"a6c99ac827f6577c","payload":[{"reference":"LIDL - MONTPELLIER","data":"17.35"},{"reference":"LIDL - LA GRANDE MOTTE","data":"0.4"},{"reference":"LIDL - LE CANNET","data":"2.06"},{"reference":"LIDL - CAGNES SUR MER","data":"2.23"},{"reference":"LIDL - LA TALAUDIERE","data":"1.46"},{"reference":"LIDL - MELUN","data":"8.01"},{"reference":"LIDL - VALLAURIS","data":"7.22"},{"reference":"LIDL - AUBERVILLIERS","data":"55.39"},{"reference":"LIDL - MEAUX LOGISTIQUE","data":"5.56"},{"reference":"LIDL - BOBIGNY","data":"8.51"},{"reference":"LIDL - LA ROCHE SUR FORON","data":"2.18"},{"reference":"LIDL - CHAMALIERES","data":"11.62"},{"reference":"LIDL - ISSOIRE","data":"9.13"},{"reference":"LIDL - NEVERS","data":"14.93"},{"reference":"LIDL - DAIX","data":"5.42"},{"reference":"LIDL - SAINT ETIENNE ROUSSEAU","data":"16.45"},{"reference":"LIDL - RIOM","data":"4.44"},{"reference":"LIDL - NICE GALLIENI","data":"5.26"},{"reference":"LIDL - VILLENEUVE LE ROI","data":"14.24"},{"reference":"LIDL - EVRY","data":"11.71"},{"reference":"BOX V3 - LIDL MARSEILLE SAINT MITRE","data":"44.29"},{"reference":"LIDL - BORDEAUX LE HAILLAN","data":"28.16"},{"reference":"LIDL - ROANNE","data":"18.9"},{"reference":"LIDL - SAVIGNEUX","data":"8.1"},{"reference":"LIDL - PONTOISE","data":"12.77"}],"topic":"SELECT reference, data FROM overconsumption_monthly WHERE date LIKE'2023-07-01';","date":"2023-07-01","settings":{"input":"2023-08-10T10:31:03.434Z","input_format":"","input_tz":"Europe/Paris","output_format":"YYYY-MM-01","output_locale":"fr-FR","output_tz":"Europe/Paris"}}

When I use your data, I get this is the msg.payload from the template node:

Bonjour,

Voici la liste des sites ayant surconsommés sur le mois de 2023-07:
LIDL - MONTPELLIER : 17.35 Go
LIDL - LA GRANDE MOTTE : 0.4 Go
LIDL - LE CANNET : 2.06 Go
LIDL - CAGNES SUR MER : 2.23 Go
LIDL - LA TALAUDIERE : 1.46 Go
LIDL - MELUN : 8.01 Go
LIDL - VALLAURIS : 7.22 Go
LIDL - AUBERVILLIERS : 55.39 Go
LIDL - MEAUX LOGISTIQUE : 5.56 Go
LIDL - BOBIGNY : 8.51 Go
LIDL - LA ROCHE SUR FORON : 2.18 Go
LIDL - CHAMALIERES : 11.62 Go
LIDL - ISSOIRE : 9.13 Go
LIDL - NEVERS : 14.93 Go
LIDL - DAIX : 5.42 Go
LIDL - SAINT ETIENNE ROUSSEAU : 16.45 Go
LIDL - RIOM : 4.44 Go
LIDL - NICE GALLIENI : 5.26 Go
LIDL - VILLENEUVE LE ROI : 14.24 Go
LIDL - EVRY : 11.71 Go
BOX V3 - LIDL MARSEILLE SAINT MITRE : 44.29 Go
LIDL - BORDEAUX LE HAILLAN : 28.16 Go
LIDL - ROANNE : 18.9 Go
LIDL - SAVIGNEUX : 8.1 Go
LIDL - PONTOISE : 12.77 Go

Cordialement

What version of Node-RED and node.js are you running? (see the startup log to get this)

Here is the flow I used which has a function node to setup the msg object:

[{"id":"f0122e0b6c045472","type":"json","z":"7c18e4fcad1f7c84","name":"","property":"payload","action":"","pretty":false,"x":650,"y":560,"wires":[["29c79f3c6abccf17"]]},{"id":"29c79f3c6abccf17","type":"string","z":"7c18e4fcad1f7c84","name":"","methods":[{"name":"replaceAll","params":[{"type":"str","value":"{"},{"type":"str","value":""}]},{"name":"replaceAll","params":[{"type":"str","value":"}"},{"type":"str","value":""}]},{"name":"replaceAll","params":[{"type":"str","value":"\"reference\":\""},{"type":"str","value":""}]},{"name":"replaceAll","params":[{"type":"str","value":"\",\"data\":\""},{"type":"str","value":" : "}]},{"name":"replaceAll","params":[{"type":"str","value":"\""},{"type":"str","value":" Go"}]},{"name":"replaceAll","params":[{"type":"str","value":","},{"type":"str","value":"\\n"}]},{"name":"replaceAll","params":[{"type":"str","value":"["},{"type":"str","value":""}]},{"name":"replaceAll","params":[{"type":"str","value":"]"},{"type":"str","value":""}]}],"prop":"payload","propout":"payload","object":"msg","objectout":"msg","x":770,"y":560,"wires":[["4195d8efc730a050","a904fd9f72fe7a84"]]},{"id":"4195d8efc730a050","type":"string","z":"7c18e4fcad1f7c84","name":"","methods":[{"name":"delRightMost","params":[{"type":"str","value":"-"}]}],"prop":"date","propout":"date","object":"msg","objectout":"msg","x":170,"y":620,"wires":[["db50d1580dde5f87"]]},{"id":"db50d1580dde5f87","type":"change","z":"7c18e4fcad1f7c84","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"\"Export de la surconsommation du \"& $$.date","tot":"jsonata"},{"t":"move","p":"payload","pt":"msg","to":"liste","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":320,"y":620,"wires":[["51c829a979cf7080"]]},{"id":"51c829a979cf7080","type":"template","z":"7c18e4fcad1f7c84","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"Bonjour,\n\nVoici la liste des sites ayant surconsommés sur le mois de {{date}}:\n{{liste}}\n\nCordialement","output":"str","x":480,"y":620,"wires":[["4c7edd1fc0578404"]]},{"id":"a904fd9f72fe7a84","type":"debug","z":"7c18e4fcad1f7c84","name":"debug 307","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":950,"y":560,"wires":[]},{"id":"4c7edd1fc0578404","type":"debug","z":"7c18e4fcad1f7c84","name":"debug 908","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":670,"y":620,"wires":[]},{"id":"b4aa5b2f54bb0134","type":"inject","z":"7c18e4fcad1f7c84","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":300,"y":500,"wires":[["172037b7ff521647"]]},{"id":"172037b7ff521647","type":"function","z":"7c18e4fcad1f7c84","name":"setup user's msg object","func":"msg = { \"_msgid\": \"a6c99ac827f6577c\", \"payload\": [{ \"reference\": \"LIDL - MONTPELLIER\", \"data\": \"17.35\" }, { \"reference\": \"LIDL - LA GRANDE MOTTE\", \"data\": \"0.4\" }, { \"reference\": \"LIDL - LE CANNET\", \"data\": \"2.06\" }, { \"reference\": \"LIDL - CAGNES SUR MER\", \"data\": \"2.23\" }, { \"reference\": \"LIDL - LA TALAUDIERE\", \"data\": \"1.46\" }, { \"reference\": \"LIDL - MELUN\", \"data\": \"8.01\" }, { \"reference\": \"LIDL - VALLAURIS\", \"data\": \"7.22\" }, { \"reference\": \"LIDL - AUBERVILLIERS\", \"data\": \"55.39\" }, { \"reference\": \"LIDL - MEAUX LOGISTIQUE\", \"data\": \"5.56\" }, { \"reference\": \"LIDL - BOBIGNY\", \"data\": \"8.51\" }, { \"reference\": \"LIDL - LA ROCHE SUR FORON\", \"data\": \"2.18\" }, { \"reference\": \"LIDL - CHAMALIERES\", \"data\": \"11.62\" }, { \"reference\": \"LIDL - ISSOIRE\", \"data\": \"9.13\" }, { \"reference\": \"LIDL - NEVERS\", \"data\": \"14.93\" }, { \"reference\": \"LIDL - DAIX\", \"data\": \"5.42\" }, { \"reference\": \"LIDL - SAINT ETIENNE ROUSSEAU\", \"data\": \"16.45\" }, { \"reference\": \"LIDL - RIOM\", \"data\": \"4.44\" }, { \"reference\": \"LIDL - NICE GALLIENI\", \"data\": \"5.26\" }, { \"reference\": \"LIDL - VILLENEUVE LE ROI\", \"data\": \"14.24\" }, { \"reference\": \"LIDL - EVRY\", \"data\": \"11.71\" }, { \"reference\": \"BOX V3 - LIDL MARSEILLE SAINT MITRE\", \"data\": \"44.29\" }, { \"reference\": \"LIDL - BORDEAUX LE HAILLAN\", \"data\": \"28.16\" }, { \"reference\": \"LIDL - ROANNE\", \"data\": \"18.9\" }, { \"reference\": \"LIDL - SAVIGNEUX\", \"data\": \"8.1\" }, { \"reference\": \"LIDL - PONTOISE\", \"data\": \"12.77\" }], \"topic\": \"SELECT reference, data FROM overconsumption_monthly WHERE date LIKE'2023-07-01';\", \"date\": \"2023-07-01\", \"settings\": { \"input\": \"2023-08-10T10:31:03.434Z\", \"input_format\": \"\", \"input_tz\": \"Europe/Paris\", \"output_format\": \"YYYY-MM-01\", \"output_locale\": \"fr-FR\", \"output_tz\": \"Europe/Paris\" } }\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":510,"y":500,"wires":[["f0122e0b6c045472"]]}]

try it and see what you get.

Yes in my node-red (v3.0.2 ) (nodejs 16.20.1) and with my flow I have a same result after template

Bonjour,

Voici la liste des sites ayant surconsommés sur le mois de 2023-07:
LIDL - MONTPELLIER : 17.35 Go
LIDL - LA GRANDE MOTTE : 0.4 Go
LIDL - LE CANNET : 2.06 Go
LIDL - CAGNES SUR MER : 2.23 Go
LIDL - LA TALAUDIERE : 1.46 Go
LIDL - MELUN : 8.01 Go
LIDL - VALLAURIS : 7.22 Go
LIDL - AUBERVILLIERS : 55.39 Go
LIDL - MEAUX LOGISTIQUE : 5.56 Go
LIDL - BOBIGNY : 8.51 Go
LIDL - LA ROCHE SUR FORON : 2.18 Go
LIDL - CHAMALIERES : 11.62 Go
LIDL - ISSOIRE : 9.13 Go
LIDL - NEVERS : 14.93 Go
LIDL - DAIX : 5.42 Go
LIDL - SAINT ETIENNE ROUSSEAU : 16.45 Go
LIDL - RIOM : 4.44 Go
LIDL - NICE GALLIENI : 5.26 Go
LIDL - VILLENEUVE LE ROI : 14.24 Go
LIDL - EVRY : 11.71 Go
BOX V3 - LIDL MARSEILLE SAINT MITRE : 44.29 Go
LIDL - BORDEAUX LE HAILLAN : 28.16 Go
LIDL - ROANNE : 18.9 Go
LIDL - SAVIGNEUX : 8.1 Go
LIDL - PONTOISE : 12.77 Go

Cordialement

but I use node : node-red-node-email and in the mail isn't the same result.

Sorry , I have read the mail with my phone and the playload is good.

the problem comes from outlook. :rage:

2 Likes

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