I've tried to search for this, but can't find anything.
Is it possible to somehow create a template with scripting that can import values from LM database and visualize it with graphs and all the imported values and send it to mail as an PDF without third party services?
The case is, im creating a energy monitoring system.
My initial tought was to just send a pre fabricated CSV file to the owner, but started to think it might be better to create a PDF document which was sent to the owner every month with graphs and values for each office area or industrial building which makes it easier to bill their different tenants.
-- adjustable informationAantalECG = 189-- Aantal armaturen MainEmail = 'example@example.be'-- mailadres voor main emailSubject = '72.01 resultaat functietest_' ..os.date('%F , %X') -- Onderwerp emailMessage = '72.01 resultaat functietest op ' ..os.date('%F , %X') -- Bericht in emailFilename = os.date("%y%m%d")..'_72.01_functietest.csv'-- Naam voor csv-bestandFINummer = 72.01-- FI nummer van het gebouw-- get current data as tablenow = os.date('*t')
current_hourandseconds = string.format("%02d", now.hour) .. ":" .. string.format("%02d", now.min)
current_date = string.format("%02d", now.day) .. "-" .. string.format("%02d", now.month) .. "-" .. now.year-- HTML text to implement in Messagehtmldata = [[<html style="font-family:Arial"><body><h1>]] ..FINummer..[[ Attest functietest </h1><p>Beste,</p><p>Hierbij bevestigen wij u dat op ]] .. current_date .. [[ om ]] .. current_hourandseconds .. [[ uur een functietest van de veiligheidsverlichting voor het gebouw met FI-nummer ]] ..FINummer..[[ werd uitgevoerd.</p><p>De resultaten van deze functietest zijn opgenomen als bijlage: ]] ..Filename..[[ van een mail verzonden vanaf example@example.be.</p><table style="width:100%"> <tr><td><b>Aantal armaturen</b></td><td><b>Resultaat</b></td></tr><tr><td>]] .. AantalECG..[[</td><td>]] ..FINummer..[[</td></tr></table><p>Wanneer u vragen heeft over het testrapport kunt u contact opnemen met example@example.be.</p><p>Dit rapport is verzonden op ]] .. current_date .. [[ om ]] .. current_hourandseconds .. [[ uur.</p></body></html>]]-- Sending main emailres, err = mailattach(MainEmail, Subject, Message , Filename, csv, 'text/csv')
log(res, err,'main email sent')
script.disable(_SCRIPTNAME)
end