The CreatorCon Call for Content is officially open! Get started here.

How to send emails from business rules

__ __2
Tera Expert

Hi.

 

I would like to create a business rule that sends an email when a specific message is output to syslog, but I don't know how to create a script to send the email.
Please let me know if you have any sample scripts.

1 ACCEPTED SOLUTION

Tushar
Kilo Sage
Kilo Sage

Hi @__ __2 

 

something like this -

 

// Check if the specific message is logged
var specificMessage = "Your specific message here";

if (gs.log.indexOf(specificMessage) !== -1) {
    var recipientEmail = "recipient@example.com";
    var emailSubject = "Syslog Message Notification";
    var emailBody = "The specific message was logged: " + specificMessage;
    
    // Send the email
    var email = new GlideEmailOutbound();
    email.setSubject(emailSubject);
    email.setBody(emailBody);
    email.addRecipient(recipientEmail);
    email.send();
}

 

 

Please, don't forget to mark my answer as correct if it solves your issue or mark it as helpful if it is relevant for you!

Regards,
Tushar

View solution in original post

3 REPLIES 3

It seems that the information I want to know is different.
I would like to know how to create a script for sending emails described in the Advanced tab of Business Rules.

Tushar
Kilo Sage
Kilo Sage

Hi @__ __2 

 

something like this -

 

// Check if the specific message is logged
var specificMessage = "Your specific message here";

if (gs.log.indexOf(specificMessage) !== -1) {
    var recipientEmail = "recipient@example.com";
    var emailSubject = "Syslog Message Notification";
    var emailBody = "The specific message was logged: " + specificMessage;
    
    // Send the email
    var email = new GlideEmailOutbound();
    email.setSubject(emailSubject);
    email.setBody(emailBody);
    email.addRecipient(recipientEmail);
    email.send();
}

 

 

Please, don't forget to mark my answer as correct if it solves your issue or mark it as helpful if it is relevant for you!

Regards,
Tushar