# E-Mail Attachment

**URL:** <https://discourse.nodered.org/t/e-mail-attachment/65630>\
**Category:** General\
**Created:** [26 July 2022 08:06 UTC](https://discourse.nodered.org/t/e-mail-attachment/65630 "2022-07-26T08:06:51Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![smanjunath211](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/smanjunath211/32/95742_2.png) [@smanjunath211](https://discourse.nodered.org/u/smanjunath211)\
**Post date:** [26 July 2022 08:06 UTC](https://discourse.nodered.org/t/e-mail-attachment/65630/1 "2022-07-26T08:06:51Z")

</div>

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

```auto
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](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/c/1c2d5e0cbe215a4217d1f80601cae98bc2138c4f.png)

---

<div class="post-metadata">

**Author:** ![UnborN](https://avatars.discourse-cdn.com/v4/letter/u/4491bb/32.png) [@UnborN](https://discourse.nodered.org/u/UnborN)\
**Post date:** [26 July 2022 23:51 UTC](https://discourse.nodered.org/t/e-mail-attachment/65630/2 "2022-07-26T23:51:36Z")

</div>

> [@smanjunath211](#):
>
> this is what is appearing

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)

> [@smanjunath211](#):
>
> `node-red-node-email 1.15.1`

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

---

<div class="post-metadata">

**Author:** ![smanjunath211](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/smanjunath211/32/95742_2.png) [@smanjunath211](https://discourse.nodered.org/u/smanjunath211)\
**Post date:** [27 July 2022 00:34 UTC](https://discourse.nodered.org/t/e-mail-attachment/65630/3 "2022-07-27T00:34:56Z")

</div>

> [@UnborN](#):
>
> Hi .. where is that message appearing ?

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,

> [@UnborN](#):
>
> by the way the latest version of the email node is `1.17.0`

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.

```auto
[{"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":[]}]

```

---

<div class="post-metadata">

**Author:** ![UnborN](https://avatars.discourse-cdn.com/v4/letter/u/4491bb/32.png) [@UnborN](https://discourse.nodered.org/u/UnborN)\
**Post date:** [27 July 2022 01:20 UTC](https://discourse.nodered.org/t/e-mail-attachment/65630/4 "2022-07-27T01:20:03Z")

</div>

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 😉  
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**

```auto
[{"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"]]}]

```

---

<div class="post-metadata">

**Author:** ![smanjunath211](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/smanjunath211/32/95742_2.png) [@smanjunath211](https://discourse.nodered.org/u/smanjunath211)\
**Post date:** [27 July 2022 04:22 UTC](https://discourse.nodered.org/t/e-mail-attachment/65630/5 "2022-07-27T04:22:34Z")

</div>

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!!

---

<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 August 2022 04:23 UTC](https://discourse.nodered.org/t/e-mail-attachment/65630/6 "2022-08-10T04:23:34Z")

</div>

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