E-Mail with dynamic content

Hello OH2 Community,

i want to monitor our sewage treatment plant. It is controlled with a PLC which uses a TCP/Modbus interface. Transmitting and recieving the data via Modbus works fine, but unfortunatly i have problems with recieving mails from openhab, which are dynamicaly generated. I used this help: https://github.com/openhab/openhab1-addons/wiki/Samples-Rules#get-an-email-when-battery-powered-devices-are-running-low-on-power

Here a snipet of my messages.rules

val string mailText =""
rule "send Mail for sewage treatment"
Item error_sewage changed
mailText = ""
if(error_sewage.state >= 1){
mailText = mailText + “Pressure error text… blalbalbal\n”

if(error_time >=1){
mailText = mailText + “Time Error text… blablabla.\n”
sendMail(mailTo,“Error sewage plant”,“Hello, \n the sewage plant has following errors:\n\n” + mailText)}

It would have been of interest to know what isn’t working, so we can only assume!

I go for the lines(changes in bold):

if(error_sewage.state as Decimal>= 1){
if(error_pressure .state as Decimal>=1){


The sending of the mail isn’t working.

I changed the file according to your suggestions, but sending still doesnt work.
Here the items
Switch error_sewage “Sewage Plant error” (sewage_err) {modbus=“plc_i_bit:299”}
Switch error_pressure “Pressure error” (sewage_err) {modbus=“plc_i_bit:300”}