Tag Event Script - Alarm Active Email

Just wanted to share a script to send an email to multiple people for multiple alarms in a DataType.

#Declare Variables and Bind to Alarm UDT Configuration Tag
eventTime = system.date.format(system.date.now(), 'h:m:s a') 
displayPath = str(alarmEvent.displayPath)
emailBody = "<b>" + alarmName + "</b> on <b>" + displayPath + "</b> went into alarm at " + eventTime + "." 
recipient1 = system.tag.read("[default]Config_AlarmEmail/Recipients[0]")
recipient2 = system.tag.read("[default]Config_AlarmEmail/Recipients[1]")
recipient3 = system.tag.read("[default]Config_AlarmEmail/Recipients[2]")
recipient4 = system.tag.read("[default]Config_AlarmEmail/Recipients[3]")
recipient5 = system.tag.read("[default]Config_AlarmEmail/Recipients[4]")	
#recipients need to be in a list form [List,etc..]
recipients = [recipient1.value,recipient2.value,recipient3.value,recipient4.value,recipient5.value]
fromaddress = system.tag.read("[default]Config_AlarmEmail/From")
emailProfile = system.tag.read("[default]Config_AlarmEmail/IgnitionEmailProfile")

#Send Email	
system.net.sendEmail(smtpProfile=emailProfile.value, fromAddr=fromaddress.value, subject="Ignition Alarm Notification", 
body=emailBody, to=recipients, html=1)
2 Likes

Why not use the alarm notification pipeline?

That would be the first choice, but the customer did not want to add the alarm notification module.