Confirmation before sending email

Yudai Yamamoto
Mega Guru

Hi,

Before sending an email, I would like to confirm whether the address of the recipient is wrong by a popup or something.

I would like to check and send if there is no problem.

Mail is intended for suggesting solutions to incidents as implemented in OOB.

 

If anyone knows how to implement it or how it can be done with OOB functionality, please let me know.

 

Thank you.

 

7 REPLIES 7

J Siva
Tera Sage

Hi @Yudai Yamamoto 
May I know from where you are trying to send email?


Shivalika
Mega Sage

Hello @Yudai Yamamoto 

 

I am assuming you mean recommended KB Articles that are sent after creating an incident? 

 

This you need to add a mail script to check the .

 

var recipientEmail = email.to; // Get the 'To' email address

 

// Check if it's a valid user in sys_user table

var user = new GlideRecord('sys_user');

user.addQuery('email', recipientEmail);

user.query();

 

if (!user.next()) {

    gs.log('Invalid recipient email: ' + recipientEmail);

    / Stop the email from being sent

}

 

Another option business rule on sys_email table, current.type == send and other filters.

 

if (current.type == 'send') {
var recipientEmail = current.recipients.toString(); // Get the 'To' email address

var user = new GlideRecord('sys_user');
user.addQuery('email', recipientEmail);
user.query();

if (!user.next()) {
gs.log('Email not sent. Invalid recipient: ' + recipientEmail);
current.setAbortAction(true); // Prevents email from being sent
}
}

 

Kindly mark my answer as helpful and accept solution if it helped you in anyway,

 

Regards,

Shivalika 

 

My LinkedIn - https://www.linkedin.com/in/shivalika-gupta-540346194

 

My youtube - https://youtube.com/playlist?list=PLsHuNzTdkE5Cn4PyS7HdV0Vg8JsfdgQlA&si=0WynLcOwN

eEISQCY

Thank you for your comment. I would like to confirm the content and address of the email associated with the case before it is sent to an external user.

Hello @Yudai Yamamoto 

 

That's what the mail script does that I shared does. It is checking the mail address in sys_user table, if it is found there, then fine, else it's aborting the action. 

 

For the content also you just need to add in between, you can do same access the body "email.body_text" if it's fine you can send it.