Using Mail action with string variable in "to" parameter

Tags: #<Tag:0x00007f43374547d8> #<Tag:0x00007f4337454710>

I am successfully able to send mail using sendMail function
boolean success=sendMail(“”,“Temperature Sensor Notification”,"Current Temperature: " + EPBUpdate)

Here, EPBUpdate is string.

Can sendMail function in following way:
var String e_id = Email_id.state
boolean success=sendMail(e_id,“Temperature Sensor Notification”,"Current Temperature: " + EPBUpdate)

Item Email_id is updated using sendCommnad.

I am getting error:
[ERROR] [untime.internal.engine.RuleEngineImpl] - Rule ‘EPB_Mail_Check’: An error occurred during the script execution: Could not invoke method: org.openhab.action.mail.internal.Mail.sendMail(java.lang.String,java.lang.String,java.lang.String) on instance: null

DSL rules are loosely typed.
e_id will become a variable of type state here.
To get a string, ask for a string.
var String e_id = Email_id.state.toString

Make sure you are not assuming that some command immediately updates a state, it doesn’t.

This solved the problem… Thank you

Is there any solution for this?

More than one, but I don’t know what context you are working in.

Usually you just have to think clearly about what you are trying to do. For example, if your rule is triggered by command do you really care what the Item state is - or do you just need to know what the command is? Use receivedCommand implicit variable.

I am trying to create an widget with input text box. That input text will be mail id which will be received by an string item and that item(mail id) will be use to get update of temperature sensor data via mail.

I asked for solution because I am looking for a delay function just like some timer base delay function available in embedded programming.

Use receivedCommand implicit variable.
New data is sent from UI as command.

Thank you… :smiley:
I will implement it.