Community Tip - You can subscribe to a forum, label or individual post and receive email notifications when someone posts a new topic or reply. Learn more! X
Sends an email with an alarm name passed in by an Expression Rule.
Parameters (passed in as arguments to ExecuteCustomObject in the Expression Rule):
import com.axeda.drm.sdk.contact.Email
/*
* ExprRuleAlarmToEmail.groovy
*
* Sends an email with an alarm name passed in by an Expression Rule.
*
* @param fromaddress - (REQ):Str email address of sender.
* @param toaddress - (REQ): Str email address of recipient
*
*
* @note Should be executed from an Expression Rule like the following:
*
* Type: Alarm
* If: Alarm.severity > 490 && Alarm.severity < 700
* Then: ExecuteCustomObject("ExprRuleAlarmToEmail", "fake_sender@axeda.com","fake_recipient@axeda.com")
*
* @author Sara Streeter <sstreeter@axeda.com>
*/
try {
String fromaddress = parameters.fromaddress
String toaddress = parameters.toaddress
String subject = "Axeda Alarm - ${alarm.name}"
String body = "You are receiving this alarm ${alarm.name} because you are subscribed to its updates."
sendEmail(fromaddress, toaddress, subject, body)
}
catch (Exception e) {
logger.error(e.message)
}
public void sendEmail(String fromAddress,String toAddress,String subject, String body) {
try {
Email.send(fromAddress, toAddress, subject, body);
} catch (AddressException ae) {
logger.error(ae);
}
}