E-Mail Attachment

Hi, i am able to send e-mail attachment through E-mail Node

node-red-node-email 1.15.1

but i am getting a message as per below, even though i have included a msg.payload with my custom message , this is what is appearing . is there a way to remove this message and replace with custom message ?

image

Hi .. where is that message appearing ? In the email body or the email subject ?
it looks like a default message when you dont provide some information to the email node.

msg.payload (string) will be the email body
msg.topic (string) will be the email subject

If you are still having problem show us what msg you are sending to the node
(sanitize any sensitive information if you have to)

by the way the latest version of the email node is 1.17.0

in the E-Mail Body.

msg.topic is appearing in subject line as expected.

I am providing msg.payload in a change node, but it is not appearing in mail body,

I updated the node and e-mail node stopped working altogether.
gave error something related to ipv4 email addressses not possible, sorry did not save message

by the way, when i use email node WITHOUT an attachment, i do get email body with msg.payload contents.

I am not able to use msg.attachments property, (dont know how to make an array of attachment) so i use a file read node to send an attachment. this is where the problem i believe.

[{"id":"f7366b8d3eb03c4d","type":"file in","z":"0c189772aa5b9793","name":"","filename":"dt_report.csv","filenameType":"str","format":"","chunk":false,"sendError":false,"encoding":"none","allProps":false,"x":410,"y":100,"wires":[["16e6ae58fa556868"]]},{"id":"2a50a132098fe514","type":"inject","z":"0c189772aa5b9793","name":"","props":[{"p":"to","v":"manjunath.s@delmontefoods.in","vt":"str"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"Email Subject","x":210,"y":100,"wires":[["f7366b8d3eb03c4d"]]},{"id":"16e6ae58fa556868","type":"e-mail","z":"0c189772aa5b9793","server":"smtp-mail.outlook.com","port":"587","secure":false,"tls":true,"name":"","dname":"E_Mail","x":570,"y":100,"wires":[]}]

I understand what is happening ..
I see in your Inject node that you first construct the msg with the email information and then read the file ..
the file in node this way would replace the msg.payload .. which in your demo flow i dont see one btw :wink:
with the Buffer data of the file.

So to solve this, first read the file and then with a Change node prepare the msg for the Email node
In the example i also show how to properly format the array needed for the attachments (using a Jsonata Expression) and the order of making the msg is important as to not destroy the msg.payload coming from the File in node.

Demo Flow

[{"id":"f7366b8d3eb03c4d","type":"file in","z":"54efb553244c241f","name":"","filename":"c:/share/test.txt","filenameType":"str","format":"","chunk":false,"sendError":false,"encoding":"none","allProps":false,"x":440,"y":3240,"wires":[["1cb19a19fa8e8212"]]},{"id":"2a50a132098fe514","type":"inject","z":"54efb553244c241f","name":"","props":[{"p":"to","v":"","vt":"date"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":210,"y":3240,"wires":[["f7366b8d3eb03c4d"]]},{"id":"a7b8946fd38e2823","type":"debug","z":"54efb553244c241f","name":"to Email node","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":860,"y":3240,"wires":[]},{"id":"1cb19a19fa8e8212","type":"change","z":"54efb553244c241f","name":"","rules":[{"t":"set","p":"to","pt":"msg","to":"manjunath.s@delmontefoods.in","tot":"str"},{"t":"set","p":"topic","pt":"msg","to":"Email Subject","tot":"str"},{"t":"set","p":"attachments","pt":"msg","to":"[\t   {\t       \"filename\": \"dt_report.csv\",\t       \"content\": payload\t        }\t]","tot":"jsonata"},{"t":"set","p":"payload","pt":"msg","to":"This is an email with an attachment from Node-red","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":660,"y":3240,"wires":[["a7b8946fd38e2823"]]}]
2 Likes

Fantastic. working like a charm...and best part I understood the problem. special thanks for the Jsonata tip.

By far this is the best interaction I had with the forum.

thanks a million!!

1 Like

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