sendMail - Invalid number of arguments

I’m having trouble getting sendMail to work in OH3; could be a binding error or something else.
My rule runs the following single line:
sendMail(“8885551234@vtext.com”,“House Power”,“House Power Alert”)

and I get the following error. I’m not sure if I need to add a ThingActions parameter or if I’m missing something else.

[ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID ‘HousePower1’ failed: ___ sendMail( ___ “6309172012@vtext.com”,“House Power”,“House Power Alert”)

  1. Invalid number of arguments. The method sendMail(ThingActions, String, String, String) is not applicable for the arguments (String,String,String); line 1, column 0, length 8
  2. Type mismatch: cannot convert from String to ThingActions; line 1, column 9, length 22

Can we see the whole rule? How are you obtaining the action?

Thanks. Here’s the code but I’m using the openhabiandevice menus so it’s auto generated except for the sendMail line.

triggers:
  - id: "1"
    configuration:
      itemName: UPSPower_HousePower
    type: core.ItemStateChangeTrigger
conditions: []
actions:
  - inputs: {}
    id: "2"
    configuration:
      type: application/vnd.openhab.dsl.rule
      script: sendMail("8885551234@vtext.com","House Power","House Power Alert")
    type: script.ScriptAction

As per the mail binding docs, you need to do a getActions() on your preconfigured mail Thing first.

I’m not sure what openhabiandevice menus are, this looks like a regular UI entered rule.

Thanks Rossko. Adding mail actions worked (copied below for reference).

triggers:
  - id: "1"
    configuration:
      itemName: UPSPower_HousePower
    type: core.ItemStateChangeTrigger
conditions: []
actions:
  - inputs: {}
    id: "2"
    configuration:
      type: application/vnd.openhab.dsl.rule
      script: >-
        val mailActions = getActions("mail","mail:smtp:eMailAcct") 

        mailActions.sendMail("8885551234@vtext.com","House Power","House Power Alert")
    type: script.ScriptAction
1 Like

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