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.

new line
#1
Hi in this for function, the texts are stringed together and sent on an email. This is for the alarm window 
But what do I have to add in the end to get a new line between each alarm entry?

I tried to send mail in the for function directly but only the last alarm is then sent by email for some reason. Why is that?

what do i use to get the number for the current row in the rows function?

What do I use to get the total number of rows in the table?

maileksport = " "
for _, row in ipairs(rows) do
  alstmaxid = math.max(alstmaxid, row.id)
  alertdate = os.date('%c', row.alerttime)
  maileksport = maileksport .. (  "Alarmnr \n \n " .. " - " .. ((alertdate .. " - ".. row.alert  )) ) --- here i want a new line
    --  mail(mailalarm, (lokasjon ..  " - ALARM " ), alertdate .. " - ".. row.alert )   --- this only send the last entry in table as alarm

   
end
Reply
#2
Either change "Content-type" header to "text/plain" or use html <br> for line breaks.
Reply
#3
Will try. Thx.
Regarding to get active row in for function. How do i get that?

Total lines is table is #row

How about the mail function, why does only the last line in table rows send an mail?
Does it overwrite the varables before the mail function is run?
Reply
#4
The current index is the first variable in the loop:
Code:
for index, row in ipairs(rows) do
  log(index)
  ...
end

It should send an email for each entry in the table. Log what the mail function returns:
Code:
res, err = mail(...)
log(res, err)
Reply


Forum Jump: