# Email with data or attachment

**URL:** <https://discourse.nodered.org/t/email-with-data-or-attachment/33992>\
**Category:** Developing Nodes\
**Created:** [9 October 2020 12:28 UTC](https://discourse.nodered.org/t/email-with-data-or-attachment/33992 "2020-10-09T12:28:57Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![flymode](https://avatars.discourse-cdn.com/v4/letter/f/f6c823/32.png) [@flymode](https://discourse.nodered.org/u/flymode)\
**Post date:** [9 October 2020 12:28 UTC](https://discourse.nodered.org/t/email-with-data-or-attachment/33992/1 "2020-10-09T12:28:57Z")

</div>

Hello everybody,

I'm new to Node Red. My programming skills are pretty basic.  
My problem is ein cannot add an email adress AND my measured object by an arduino to my email preparation function.

my task is basically reading sensordata with an arduino, show it on grafana and the node red dashboard. Additionally I like to send send it an emailadresse that can be typed in a textfield and is varified by klicking the do stuff button. I can send an email to the adresse but cannot add the data. any ideas or tips? the second msg.payload in the Email\_Preparation-function supposed to be the measured data as an object.

optionally would be nice when i could add more than the current data as a .csv-file as an email attachment (maybe stored data from influx db).

```auto
[
    {
        "id": "66600b90.c5c1a4",
        "type": "ui_button",
        "z": "c82c7bb9.be4ba8",
        "name": "",
        "group": "8211b627.bbb5b8",
        "order": 3,
        "width": 0,
        "height": 0,
        "passthru": false,
        "label": "Do stuff",
        "tooltip": "",
        "color": "black",
        "bgcolor": "blue",
        "icon": "",
        "payload": "textInput",
        "payloadType": "flow",
        "topic": "",
        "x": 360,
        "y": 1140,
        "wires": [
            [
                "df57b78b.5848e8",
                "1344cacd.e3faf5"
            ]
        ]
    },
    {
        "id": "7cac6136.c54a8",
        "type": "ui_text_input",
        "z": "c82c7bb9.be4ba8",
        "name": "",
        "label": "email hier",
        "tooltip": "",
        "group": "8211b627.bbb5b8",
        "order": 1,
        "width": 0,
        "height": 0,
        "passthru": true,
        "mode": "text",
        "delay": "1000",
        "topic": "",
        "x": 180,
        "y": 1060,
        "wires": [
            [
                "f247e268.089cb"
            ]
        ]
    },
    {
        "id": "f247e268.089cb",
        "type": "change",
        "z": "c82c7bb9.be4ba8",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "textInput",
                "pt": "flow",
                "to": "payload",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 370,
        "y": 1060,
        "wires": [
            [
                "4aa2781c.5c92b8"
            ]
        ]
    },
    {
        "id": "4aa2781c.5c92b8",
        "type": "switch",
        "z": "c82c7bb9.be4ba8",
        "name": "is text empty?",
        "property": "textInput",
        "propertyType": "flow",
        "rules": [
            {
                "t": "empty"
            },
            {
                "t": "else"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 560,
        "y": 1060,
        "wires": [
            [
                "26cda3fe.081fbc"
            ],
            [
                "b02283b8.eaba4"
            ]
        ]
    },
    {
        "id": "26cda3fe.081fbc",
        "type": "change",
        "z": "c82c7bb9.be4ba8",
        "name": "enabled false",
        "rules": [
            {
                "t": "set",
                "p": "enabled",
                "pt": "msg",
                "to": "false",
                "tot": "bool"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 750,
        "y": 1040,
        "wires": [
            [
                "8af92438.a1a518"
            ]
        ]
    },
    {
        "id": "b02283b8.eaba4",
        "type": "change",
        "z": "c82c7bb9.be4ba8",
        "name": "enabled true",
        "rules": [
            {
                "t": "set",
                "p": "enabled",
                "pt": "msg",
                "to": "true",
                "tot": "bool"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 750,
        "y": 1080,
        "wires": [
            [
                "8af92438.a1a518"
            ]
        ]
    },
    {
        "id": "8af92438.a1a518",
        "type": "link out",
        "z": "c82c7bb9.be4ba8",
        "name": "",
        "links": [
            "4727ccfc.b1c494"
        ],
        "x": 855,
        "y": 1060,
        "wires": []
    },
    {
        "id": "4727ccfc.b1c494",
        "type": "link in",
        "z": "c82c7bb9.be4ba8",
        "name": "",
        "links": [
            "8af92438.a1a518"
        ],
        "x": 35,
        "y": 1140,
        "wires": [
            [
                "66600b90.c5c1a4"
            ]
        ]
    },
    {
        "id": "3e9b81e7.4b842e",
        "type": "inject",
        "z": "c82c7bb9.be4ba8",
        "name": "Init with empty string",
        "topic": "",
        "payload": "",
        "payloadType": "str",
        "repeat": "",
        "crontab": "",
        "once": true,
        "onceDelay": 0.1,
        "x": 180,
        "y": 980,
        "wires": [
            [
                "7cac6136.c54a8"
            ]
        ]
    },
    {
        "id": "ce657448.4ebe58",
        "type": "e-mail",
        "z": "c82c7bb9.be4ba8",
        "server": "smtp.gmail.com",
        "port": "465",
        "secure": true,
        "tls": true,
        "name": "",
        "dname": "EMAIL_TO",
        "x": 1010,
        "y": 1120,
        "wires": []
    },
    {
        "id": "df57b78b.5848e8",
        "type": "function",
        "z": "c82c7bb9.be4ba8",
        "name": "my function that does stuff",
        "func": "msg.payload = \"Eine Email mit den Messdaten wird an \"+ msg.payload+\" gesendet.\"\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 750,
        "y": 1180,
        "wires": [
            [
                "1eed477b.0e92c9"
            ]
        ]
    },
    {
        "id": "1eed477b.0e92c9",
        "type": "ui_text",
        "z": "c82c7bb9.be4ba8",
        "group": "8211b627.bbb5b8",
        "order": 2,
        "width": 0,
        "height": 0,
        "name": "",
        "label": "Bitte warten. ",
        "format": "{{msg.payload}}",
        "layout": "row-left",
        "x": 1030,
        "y": 1180,
        "wires": []
    },
    {
        "id": "1344cacd.e3faf5",
        "type": "function",
        "z": "c82c7bb9.be4ba8",
        "name": "Email_Preparation",
        "func": "var emailadresse = msg.payload\nmsg.to= emailadresse\nmsg.from=\"mobileladestation@gmail.com\"\nvar d=new Date();\nvar message=\"\";\n msg.topic=\"Messwerte der mobilen Ladestation\";\n message=\"Hier die aktuellen Messwerte der Ladestation \"\n msg.payload=\"Messdaten von: \"+ d + message + msg.payload ;\n return msg;\n\n ",
        "outputs": 1,
        "noerr": 0,
        "x": 730,
        "y": 1140,
        "wires": [
            [
                "ce657448.4ebe58"
            ]
        ]
    },
    {
        "id": "8211b627.bbb5b8",
        "type": "ui_group",
        "z": "",
        "name": "Kapazität",
        "tab": "b7e1c72f.096ba8",
        "order": 2,
        "disp": true,
        "width": 24,
        "collapse": false
    },
    {
        "id": "b7e1c72f.096ba8",
        "type": "ui_tab",
        "z": "",
        "name": "Dashboard",
        "icon": "dashboard",
        "order": 1
    }
]

```

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [9 October 2020 14:50 UTC](https://discourse.nodered.org/t/email-with-data-or-attachment/33992/2 "2020-10-09T14:50:01Z")

</div>

> [@flymode](#):
>
> I can send an email to the adresse but cannot add the data. any ideas or tips?

Did you read the `email` node's help tab?  
 ![Screen Shot 2020-10-09 at 10.49.36 AM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/4/b4ef7925f02ff84506a0e6c5326ad14f09b541de.png)

---

<div class="post-metadata">

**Author:** ![softy2k](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/softy2k/32/23707_2.png) [@softy2k](https://discourse.nodered.org/u/softy2k)\
**Post date:** [9 October 2020 15:00 UTC](https://discourse.nodered.org/t/email-with-data-or-attachment/33992/3 "2020-10-09T15:00:20Z")

</div>

Take a look here : [Email with 3 attachments?](https://discourse.nodered.org/t/email-with-3-attachments/28110)

---

<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:** [8 December 2020 15:00 UTC](https://discourse.nodered.org/t/email-with-data-or-attachment/33992/4 "2020-12-08T15:00:22Z")

</div>

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