This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Formatting email text
#4
I've tried to re-create this issue and it seems that the message source won't be helpful here.
Try this reworked script with extra line breaks and see if it helps.
Code:
value = event.getvalue()

require('user.sendmail')
require('user.emails')

header_alarm = 'Tere! <br><br> <b>SV1</b> automaatikasüsteemis on tuvastatud järgmised häired: <br><br>'
header_ok = 'Tere! <br><br> <b>SV1</b> automaatikasüsteemi häired on taastunud ning süsteem on töökorras.<br><br>Kokkuvõte häiretest: <br><br>'

footer = '<br><br><br><br><i>Email on genereeritud automaatikasüsteemi poolt. Palume mitte sellele emailile vastata!<br><br>Parimate soovidega,<br>Building Automation System OÜ</i>'

text_alarm = ' - <span style="color:red;font-weight:bold">ALARM!</span><br>'
text_ok = ' - <span style="color:green;font-weight:bold">OK</span><br>'

buf = {}

buf[ #buf + 1 ] = value > 0 and header_alarm or header_ok

alarms = grp.tag('SV1-ALARMS')

for _, alarm in ipairs(alarms) do
  buf[ #buf + 1 ] = alarm.name
  buf[ #buf + 1 ] = alarm.value and text_alarm or text_ok
end

buf[ #buf + 1 ] = footer

message = table.concat(buf, '\n')

res, err = mail(emails, 'Hooneautomaatika', message)
grp.checkupdate('38/4/6', err ~= nil)
Reply


Messages In This Thread
Formatting email text - by fleeceable - 30.09.2022, 09:02
RE: Formatting email text - by admin - 30.09.2022, 09:30
RE: Formatting email text - by fleeceable - 03.10.2022, 08:36
RE: Formatting email text - by admin - 03.10.2022, 09:24

Forum Jump: