Email with data or attachment

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).

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

Did you read the email node's help tab?
Screen Shot 2020-10-09 at 10.49.36 AM

Take a look here : Email with 3 attachments?

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