NEWS
JScript nach Blockly
-
Hallöchen,
ich kann per JS erfolgreich eine Email verschicken. Toll.
Ich möchte aber gerne die Logik vom Blockly nutzen um vorher meine HTML-Ausgaben mit tollen Daten zu füttern.Wie bringe ich ein JS Script ins Blockly?
Das Script:
sendTo('email.0', {
from: 'my@home.de ',
to: 'dontwritetothis@gmail.com',
subject: 'Message from ioBroker',
html: '<p>Embedded image: <img src="cid:HEADER"></p>',
attachments:[
{
path: '/opt/iobroker/iobroker-data/files/0_userdata.0/smarthome_security.png',
cid: 'HEADER',
},
]
}) -
@dapanic sagte in JScript nach Blockly:
Wie bringe ich ein JS Script ins Blockly?
Mit einem passend konfigurierten "sendTo"-Block:
-
@codierknecht
Alles klar...
soweit verstanden und klappt auch, bis auf die Attachments.Ein Tipp wie ich
attachments:[ { path: '/opt/iobroker/iobroker-data/files/0_userdata.0/smarthome_security.png', cid: 'HEADER', }, ]
Als Parameter übergebe? Klar, den Parameter "attachment" definieren, aber was schreibe ich rein. Bisher sind alle versuche gescheiert
.Cannot send email: TypeError: Cannot use 'in' operator to search for 'contentTransferEncoding' in [{path: '/opt/iobroker/iobroker-data/files/0_userdata.0/smarthome_security.png',cid: 'HEADER'}]
MOD-EDIT: Code in code-tags gesetzt!
-
@dapanic
so:
oder so:
in der Funktion:
const rv = {}; if (path) rv.path = path; if (cid) rv.cid = cid; return [rv];
-
-
@dapanic sagte: "attachment" definieren, aber was schreibe ich rein.
-
Danke, so klappt es.