The method sendMail(String, String, String) is undefined - is there a workaround

Is there a workaround for Eclipse Smarthome Designer throwing an error with Openhab2 on every mail entry in a rule?
The error is

The method sendMail(String, String, String) is undefined

The email command works OK, but the errors make it a challenge to spot any other code errors. I’ve updated to a Snapshot build which works better with new rules, but the false errors remain. Is there a way of defining the sendMail command manually?

I have created a lambha sendMail function.
WIth this workarround this fake error only appears once and always at the beginning so it is easy to “filter” it from real errors.

Don’t suppose you would be kind enough to post it on here with the personal bits removed? I’ve never been able to get my head around Lambda’s

I am currently travelling therefore no access to my OH2 code.
Will follow up in 2 weeks.

Thanks

Out of my head without having it tested.

val Functions$Function3<String,String,String ,String> sendMail_lambha=
[email, subject,body
      	|
  			sendMail(email,subject,body)
   ""
]

rule "Test"
when
	System started
then
	sendMail_lambha.apply ("test@test","test","testbody")
end
1 Like

Thanks very much, I ended up doing something slightly different inspired by your code.
I created 2 items

String MailSubject
String MailContent

and a single rule in its own rules file

rule "send Email"
when Item MailContent changed then if (MailContent.state !=NULL && MailSubject !=NULL)	{
val Subject = MailSubject.state.toString
val Content = MailContent.state.toString
sendMail("myEmailAddress", Subject, Content) }
end

I send mail by postUpdate to “MailSubject” and “MailContent” The only file showing bogus errors is the one containing the single email send rule

This is not thread safe.
If it is used across different rules, the MailSubject might be changed, e.g. wrong Subject for the MailContent or if MailContent is change at once by different rules you might loose a whole message