Having troule with sending html table via email.

124 views
Skip to first unread message

ady....@gmail.com

unread,
Apr 19, 2018, 1:23:13 PM4/19/18
to Node-RED
Hi, 
         I am displaying data (on dashboard) from sqlite database using template node. The template node includes a following script;

<table style="width:100%">
  <tr>
    <th>Storage</th>
<th>Location</th>
  </tr>
  <tr ng-repeat="x in msg.payload | limitTo:100">
    <td>{{msg.payload[$index].storage_name}}</td>
<td>{{msg.payload[$index].location_name}}</td> 
    
  </tr>
</table>


This works fine. However, I want to send such generated table via email as well. Any suggestions for this?
Thanks!
-Aditya

Mark Setrem

unread,
Apr 19, 2018, 1:37:38 PM4/19/18
to Node-RED
what have you tried?. It should be easy to build the html in a function node and pass it to an email out node

ady....@gmail.com

unread,
Apr 19, 2018, 2:25:54 PM4/19/18
to Node-RED
Hi,
Thanks!
        I have tried following in the function node;

msg.payload = '<html> <body> <table style="width:100%">  <tr>  <th>Storage</th> <th>Location</th>    </tr>   <tr ng-repeat="x in msg.payload | limitTo:100">     <td>{{msg.payload[$index].storage_name}}</td>     <td>{{msg.payload[$index].location_name}}</td>   </tr> </table> </body> </html>';
return msg;

It is connected to Email out node. It sends an email with headers printed fine. Probably, the issue is with the "ng-repeat" as it's not generating the rows.

-Aditya

Dave C-J

unread,
Apr 19, 2018, 2:28:43 PM4/19/18
to node...@googlegroups.com
the dashboard uses angular which is what handles ng-repeat - the editor does not.
You can use the basic template node that does support mustache which has a repeat like capability (but isn't ng-repeat)

Zenofmud

unread,
Apr 19, 2018, 2:28:44 PM4/19/18
to node...@googlegroups.com
You might try using a change node and the jsonata format.

--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+u...@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.
To view this discussion on the web, visit https://groups.google.com/d/msgid/node-red/e3337693-7fe4-44ce-9915-6343e3dbd731%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

ady....@gmail.com

unread,
Apr 19, 2018, 2:44:18 PM4/19/18
to Node-RED
Thanks! 
I will try this out.
Reply all
Reply to author
Forward
0 new messages