# Question about sending email formatting for payload

**URL:** <https://discourse.nodered.org/t/question-about-sending-email-formatting-for-payload/26464>\
**Category:** General\
**Created:** [11 May 2020 07:29 UTC](https://discourse.nodered.org/t/question-about-sending-email-formatting-for-payload/26464 "2020-05-11T07:29:00Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Thalios](https://avatars.discourse-cdn.com/v4/letter/t/c89c15/32.png) [@Thalios](https://discourse.nodered.org/u/Thalios)\
**Post date:** [11 May 2020 07:29 UTC](https://discourse.nodered.org/t/question-about-sending-email-formatting-for-payload/26464/1 "2020-05-11T07:29:01Z")

</div>

Hello, new NodeRed player here.

Having fun extracting data from my Duet 3 card on my 3D Printer to email me useful informations.

So far, I have all I need, except the formatting of the data send in the email is horrible.

I get this:

```auto
{"status":"Printing from SD card","printPercent":80.9,"printTimeLeft":3751.6,"x":135.425,"y":121.557,"z":91.17,"currentBedTemp":50,"currentHotendTemp":210.3,"activeBedTemp":50,"activeHotendTemp":210,"stateBed":"Active","stateHotend":"Active","fileName":"0:/gcodes/cam holder.gcode"}

```

Is it possible to get this instead:

```auto
Status : Printing from SD card
printPercent : 80.9
printTimeLeft : 3751.6
x : 135.425
etc.

```

The format is in a single line of data right now and is kinda hard to read. I've messed with CSV but it is not really helping my cause as all I can get is all the data without the description, but still all on a single line.

I was thinking of inserting a break between each message in the payload. Is that possible?

Thanks in advance for the help!

---

<div class="post-metadata">

**Author:** ![Thalios](https://avatars.discourse-cdn.com/v4/letter/t/c89c15/32.png) [@Thalios](https://discourse.nodered.org/u/Thalios)\
**Post date:** [11 May 2020 07:33 UTC](https://discourse.nodered.org/t/question-about-sending-email-formatting-for-payload/26464/2 "2020-05-11T07:33:19Z")

</div>

Also, when I look at the debug, it shows up exactly like I want it for some reason with a JSON object converter.

See attached screenshot. This is the exact way i want it to show up..

 ![Screen Shot 2020-05-11 at 3.31.29 AM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/a/1a8be7e7ea0836edd7e23dc71cbc2357804f713a.png)

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [11 May 2020 07:52 UTC](https://discourse.nodered.org/t/question-about-sending-email-formatting-for-payload/26464/3 "2020-05-11T07:52:18Z")

</div>

That is not a JSON object, that is a Javascript object. A JSON object is a string, which I assume is what you started with. So it isn't a horrible email format at all, it is ideal as it is JSON. So now all you have to do is to build the text you want from the object. Start by reading the node red docs [Working with Messages](https://nodered.org/docs/user-guide/messages) which will show you how to access the various attributes. Then I suggest maybe using a Template node (not ui-template) to format the text for putting in the email. The Information panel for the node shows you how to insert values from the payload into the string returned.  
Feed the javascript object into the template, not the original JSON.

---

<div class="post-metadata">

**Author:** ![Thalios](https://avatars.discourse-cdn.com/v4/letter/t/c89c15/32.png) [@Thalios](https://discourse.nodered.org/u/Thalios)\
**Post date:** [11 May 2020 08:15 UTC](https://discourse.nodered.org/t/question-about-sending-email-formatting-for-payload/26464/4 "2020-05-11T08:15:44Z")

</div>

Thank YOU!! Template node was exactly what I was looking for!

Yes, I meant Javascript object, not JSON object.

Now I get this pretty sexy email:

 ![Screen Shot 2020-05-11 at 4.14.53 AM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/e/9ed770e617967baa65fd2df50e8e9a2f1efb5836.png)

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [11 May 2020 08:17 UTC](https://discourse.nodered.org/t/question-about-sending-email-formatting-for-payload/26464/5 "2020-05-11T08:17:26Z")

</div>

Now to make it nicer... Use html in that template to get colour & formatting 🙂

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [10 July 2020 08:17 UTC](https://discourse.nodered.org/t/question-about-sending-email-formatting-for-payload/26464/6 "2020-07-10T08:17:30Z")

</div>

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