Artikel Datenbank Mail

Hallo,
kann mir vielleicht jemand helden?

Ich möchte mit dem Form-Node eine Menge und einen Artikel in die Datenbank schreiben. das funktioniert auch..

Mit dem Button soll die Datenbank augelesen und der Inhalt (Artikel, Menge) per mail gesendet werden.

Meine Lösung funktioniert, hat aber viele Nachteile. Ich muss eine genaue Anzahl an Variablen anlegen. Wenn die Anzahl der Variablen mit den Feldern der DB nicht übereinstimmt wird keine Mail gesendet.
Es muss einen einfacheren weg geben?! Ich komme aber nicht drauf.

[{"id":"f7ff8342.16ecd8","type":"tab","label":"Flow 5","disabled":false,"info":""},{"id":"defe228c.3c2f","type":"ui_form","z":"f7ff8342.16ecd8","name":"","label":"","group":"d29cda1f.c7835","order":1,"width":6,"height":"5","options":[{"label":"brauche","value":"brauche","type":"text","required":true,"rows":null},{"label":"Menge","value":"Menge","type":"number","required":true,"rows":null}],"formValue":{"brauche":"","Menge":""},"payload":"","submit":"submit","cancel":"cancel","topic":"","x":230,"y":440,"wires":[["8ac25a63.3c99d","f9b5f120.ff7358"]],"icon":"font-awesome/fa-heartbeat"},{"id":"8ac25a63.3c99d","type":"debug","z":"f7ff8342.16ecd8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":490,"y":440,"wires":[]},{"id":"54cd0d3b.2a003c","type":"mysql","z":"f7ff8342.16ecd8","mydb":"38fcd553.254bf2","name":"Einkauf","x":680,"y":540,"wires":[["21cf351f.91c812"]]},{"id":"f9b5f120.ff7358","type":"function","z":"f7ff8342.16ecd8","name":"Eintrag Datenbank","func":"var aus = \"INSERT INTO zettel (Produkt,Menge)\"\naus = aus+\"VALUES ('\"  + msg.payload.brauche + \"','\"  + msg.payload.Menge + \"');\"\n\nmsg.topic=aus;\n\nreturn msg;\n","outputs":1,"noerr":0,"x":410,"y":540,"wires":[["54cd0d3b.2a003c"]]},{"id":"21cf351f.91c812","type":"debug","z":"f7ff8342.16ecd8","name":"","active":true,"console":"false","complete":"false","x":930,"y":540,"wires":[]},{"id":"96f8166a.3c107","type":"comment","z":"f7ff8342.16ecd8","name":"","info":"Mit dem Form-Node wird die Menge und der Artikel in die Datenbank geschrieben. \n\nMit dem Button soll die Datenbank augelesen und der Inhalt (Artikel, Menge) per mail gesendet werden.\n\nMeine Lösung funktioniert, hat aber viele Nachteile. Ich muss eine genause Anzahl an Variablen anlegen. Wenn die Anzahl der Variablen mit den Feldern der DB nicht übereinstimmt wird keine Mail gesendet. \nEs muss eine einfacheren weg geben?!","x":690,"y":720,"wires":[]},{"id":"e337cd46.3992e8","type":"mysql","z":"f7ff8342.16ecd8","mydb":"38fcd553.254bf2","name":"Einkauf","x":660,"y":860,"wires":[["6a0c39ab.f746c8","db6fba52.ef20c8"]]},{"id":"d2087a63.fe01","type":"function","z":"f7ff8342.16ecd8","name":"Abfrage_Datenbank","func":"msg.topic= 'SELECT Produkt,Menge FROM zettel'\n\nreturn msg;\n\n//  ORDER BY id DESC LIMIT 12","outputs":1,"noerr":0,"x":440,"y":860,"wires":[["e337cd46.3992e8"]]},{"id":"6c775c0c.98bf44","type":"debug","z":"f7ff8342.16ecd8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":1150,"y":820,"wires":[]},{"id":"a03166fd.3a92","type":"e-mail","z":"f7ff8342.16ecd8","server":"mail.gmx.net","port":"465","secure":true,"tls":false,"name":"xxx@xxx.de","dname":"","x":1150,"y":960,"wires":[]},{"id":"6a0c39ab.f746c8","type":"debug","z":"f7ff8342.16ecd8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":930,"y":800,"wires":[]},{"id":"4b944cd5.e31ac4","type":"ui_button","z":"f7ff8342.16ecd8","name":"Senden","group":"d29cda1f.c7835","order":1,"width":0,"height":0,"passthru":true,"label":"Mail Anfordern","tooltip":"","color":"","bgcolor":"","icon":"","payload":"true","payloadType":"bool","topic":"","x":220,"y":860,"wires":[["d2087a63.fe01"]]},{"id":"db6fba52.ef20c8","type":"function","z":"f7ff8342.16ecd8","name":"Array","func":"\nvar a = msg.payload[0].Produkt\nvar b = msg.payload[1].Produkt\nvar c = msg.payload[2].Produkt\nvar d = msg.payload[3].Produkt\nvar e = msg.payload[4].Produkt\nvar f = msg.payload[5].Produkt\nvar g = msg.payload[6].Produkt\nvar h = msg.payload[7].Produkt\nvar i = msg.payload[8].Produkt\nvar j = msg.payload[9].Produkt\nvar k = msg.payload[10].Produkt\nvar l = msg.payload[11].Produkt\nvar aa = msg.payload[0].Menge\nvar bb = msg.payload[1].Menge\nvar cc = msg.payload[2].Menge\nvar dd = msg.payload[3].Menge\nvar ee = msg.payload[4].Menge\nvar ff = msg.payload[5].Menge\nvar gg = msg.payload[6].Menge\nvar hh = msg.payload[7].Menge\nvar ii = msg.payload[8].Menge\nvar jj = msg.payload[9].Menge\nvar kk = msg.payload[10].Menge\nvar ll = msg.payload[11].Menge\n\nmsg.payload = \n( a + \" \"+aa +'\\n') +\n( b + \" \"+bb +'\\n') +\n( c + \" \"+cc +'\\n') +\n( d + \" \"+dd +'\\n') +\n( e + \" \"+ee +'\\n') +\n( f + \" \"+ff +'\\n') +\n( g + \" \"+gg +'\\n') +\n( h + \" \"+hh +'\\n') +\n( i + \" \"+ii +'\\n') +\n( j + \" \"+jj +'\\n') +\n( k + \" \"+kk +'\\n') +\n( l + \" \"+ll +'\\n') ;\n\nmsg.topic = \"zettel\";\nreturn msg;\n","outputs":1,"noerr":0,"x":870,"y":940,"wires":[["6c775c0c.98bf44","a03166fd.3a92"]]},{"id":"da239ebd.fe979","type":"function","z":"f7ff8342.16ecd8","name":"","func":"var a = msg.payload[0].Produkt\nvar b = msg.payload[1].Produkt\nvar c = msg.payload[2].Produkt\nvar d = msg.payload[3].Produkt\nvar e = msg.payload[4].Produkt\nvar f = msg.payload[5].Produkt\nvar g = msg.payload[6].Produkt\nvar h = msg.payload[7].Produkt\nvar i = msg.payload[8].Produkt\nvar j = msg.payload[9].Produkt\nvar k = msg.payload[10].Produkt\n//var l = msg.payload[11].Produkt\nvar aa = msg.payload[0].Menge\nvar bb = msg.payload[1].Menge\nvar cc = msg.payload[2].Menge\nvar dd = msg.payload[3].Menge\nvar ee = msg.payload[4].Menge\nvar ff = msg.payload[5].Menge\nvar gg = msg.payload[6].Menge\nvar hh = msg.payload[7].Menge\nvar ii = msg.payload[8].Menge\nvar jj = msg.payload[9].Menge\nvar kk = msg.payload[10].Menge\n//var ll = msg.payload[11].Menge\n\nmsg.payload = \n( a + \" \"+aa +'\\n') +\n( b + \" \"+bb +'\\n') +\n( c + \" \"+cc +'\\n') +\n( d + \" \"+dd +'\\n') +\n( e + \" \"+ee +'\\n') +\n( f + \" \"+ff +'\\n') +\n( g + \" \"+gg +'\\n') +\n( h + \" \"+hh +'\\n') +\n( i + \" \"+ii +'\\n') +\n( j + \" \"+jj +'\\n') +\n( k + \" \"+kk +'\\n') ;\n//( l + \" \"+ll +'\\n') ;\nmsg.topic = \"zettel\";\nreturn msg;\n","outputs":1,"noerr":0,"x":784,"y":1089,"wires":[[]]},{"id":"d29cda1f.c7835","type":"ui_group","z":"","name":"Einkaufzettel","tab":"614c4072.9e2738","order":1,"disp":true,"width":"6","collapse":false},{"id":"38fcd553.254bf2","type":"MySQLdatabase","z":"","name":"","host":"127.0.0.1","port":"3306","db":"Einkauf","tz":""},{"id":"614c4072.9e2738","type":"ui_tab","z":"","name":"Einkaufzettel","icon":"dashboard","order":17,"disabled":false,"hidden":false}]