Need help with script to send mail

Following the document on Mail - Bindings
I setup a imap binding, I’m trying to test if the binding will work so I created a new script using application/javascript.

here is my code
mailActions = getActions(“mail”,“mail:imap:6426400d3f”)
mailActions.sendMail(“”, “openhab test”, “test of the openhab”)

here is the error I get
2023-10-09 14:46:13.720 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID ‘2c1011fc22’ failed: org.graalvm.polyglot.PolyglotException: ReferenceError: “getActions” is not defined

What am I doing wrong? Is this Javascript or java? I tried the blocky, but I need to read up more on that stuff. Any help would be appreciated.

var Actions = Java.type("org.openhab.core.model.script.actions.Things");
var mailActions = Actions.getActions("mail","mail:smtp:be93f84a0f");
mailActions.sendMail("", "subject", "text");

Does this work ?

Your code is DSL syntax.

The reference docs for doing this with the javascript helper libraries are here:

1 Like

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