Inbound email action in HR Case Management is not working for Non-Allowed list of users.

GovindaVarma
Tera Contributor

Hi Team, 

We have a requirement to create a inbound email action in HR Case Management.

Requirement:- If a user sends a mail to company123@gmail.com then if the user is not in the allowed list then the user should get a Rejection Email, but it was not working as expected, we need your help to fix this issue asap. Thanks!

 

 

Regards,

Govind Varma T.

1 REPLY 1

RB5
Tera Contributor

Hi @GovindaVarma ,

You need to create inbound action similar to below script to achieve this

(function runInboundEmailAction(email, email_action, event) {
var senderEmail = email.origemail; // Get the sender's email address

// Check if the sender is in the "Allowed Users" table
var allowedUser = new GlideRecord('x_your_scope_allowed_users'); // Replace with your table's sys_id
allowedUser.addQuery('email_address', senderEmail);
allowedUser.query();

if (!allowedUser.next()) {
// Send rejection email
var gr = new GlideEmailOutbound();
gr.setSubject("Access Denied");
gr.setBody("Your email was not processed because you are not on the allowed list.");
gr.setTo(senderEmail);
gr.insert();
}
})(email, email_action, event);