Logic Machine Forum
Send e-mail - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: Send e-mail (/showthread.php?tid=1112)



Send e-mail - Daponte - 25.11.2017

Hello,
I needed to send an email when an event with a group address occurs. Does anyone have an example?



RE: Send e-mail - Erwin van der Zwart - 26.11.2017

Hi,

Just use the build in mail function and trigger it as event based script:
Code:
-- make sure mail settings are set in common functions library before using this function
subject = 'E-mail test'
message = 'Testing e-mail'
mail('user@example.com', subject, message)
BR,

Erwin


RE: Send e-mail - Daponte - 27.11.2017

Thanks


Send e-mail - Daponte - 27.11.2017

Hello,
I need to send a value from storage by email, someone has an example?



RE: Send e-mail - admin - 27.11.2017

For event value you can use an event script:
Code:
value = event.getvalue()

subject = 'E-mail test'
message = 'Event value is ' .. tostring(value)
mail('user@example.com', subject, message)

For storage value you need a scheduled script. But, if you want to send a value on each storage value change you should use a virtual object instead because you cannot attach an event script to storage changes.
Code:
value = storage.get('myvalue')

subject = 'E-mail test'
message = 'Storage value is ' .. tostring(value)
mail('user@example.com', subject, message)



RE: Send e-mail - Daponte - 27.11.2017

Thank you very much


RE: Send e-mail - d.r soutras - 10.10.2021

Hello guys!
A little bit of help here..

I have cycling send from a GA that comes from a generator. Can we adjust the code to send the email only if the GA changes it’s state. So an email with subject ‘Generator On’ will be sent when the GA is 1 and an email with subject ‘Generator Off’ will be sent when the GA is 0.

Thank you in advance!!


RE: Send e-mail - Daniel - 11.10.2021

Something like that would do, event script
Code:
value = event.getvalue()
mydata = storage.get('myobjectdata', 2)

if value then
  if value ~= mydata then
    --emial for on
  end
else
 
  if value ~= mydata then
   --email for off
  end
end 

storage.set('myobjectdata', value)



RE: Send e-mail - d.r soutras - 11.10.2021

As always… your script works like a charm!!!!
Thank you very much!!