An error occurred during the script execution: index=3, size=3

Just installed latest stable build of Openhab2.
Rebuilding all my rules from a 3 year old version.

What am I doing wrong in this rule?
sendMail(“blabla@bla.com”, “CameraSnaps Initiated”, " " + now.getMonthOfYear + “/” + now.getDayOfMonth + " | " + now.getHourOfDay + “:” + now.getMinuteOfHour + " ")

Log file state: An error occurred during the script execution: index=3, size=3

Mail action has changed since v1, which one are you using?
What makes you think this is the offending line? These kinds of messages are a nuisance in not giving you many clues!

This error is usually from trying to access an invalid position in an array/list. As @rossko57 said, I don’t think what you posted is what causes the error. Can you post the whole rule?

If i comment out that line, everything works; if I uncomment it; it produces that error:

val mailActions = getActions(“mail”,“mail:smtp:1234aaaa”)

rule “CameraSnaps Rule”
when
Item CameraSnaps received command ON
then

sendMail(“bla@bla.com”, “CameraSnaps Initiated”, " " + now.getMonthOfYear + “/” + now.getDayOfMonth + " | " + now.getHourOfDay + “:” +
executeCommandLine(“bash /etc/openhab2/CameraSnaps.sh”)

End

And I think i see it already :slight_smile: I’ll post fix in a sec

Yeap thanks. This copying and pasting is gonna kill me changing all my rules over.
The fix is…sendmail is different than my current version. I didn’t use mail.Actions.sendMail.

Syntax to use it is:
mailActions.sendMail(“bla@bla.com”, “CameraSnaps Initiated”, " " + now.getMonthOfYear + “/” + now.getDayOfMonth + " | " + now.getHourOfDay + “:” + now.getMinuteOfHour + " ")

1 Like