Inbound Action for incoming emails that dont match any of the conditions

sreed
Kilo Explorer

We are having a problem with users emailing the service-now mailbox instead of the Service Desk. We would like to change our inbound email rules so that if no matches are found the last action is to trigger a reply email to the sender indicating that they should be emailing the our service desk rather than the service-now email address. Has anyone done something like this? Im having trouble finding a way to get an inbound email script to create no record but still produce a notification. I assumed I could have it create an event but it just skips the rule entirely if there is no record to create. Anyone have an idea for me?


Thanks!

6 REPLIES 6

Brad Tilton
ServiceNow Employee
ServiceNow Employee

Something like this may work. Firing the notification and aborting the record from creating.



gs.eventQueue();
current.setAbortAction(true);


foster1
Kilo Explorer

Hi,


did you manage to get this working, we have exactly the same issue?



Foster


justin_drysdale
Mega Guru

I don't have experience doing this so I don't know if it will work.   But I think it will!



You can create a business rule on sys_email that is conditionalized to the situation you describe.   I image the conditions are target field(instance😞 empty, created: today, type: received and email.to doesn't contain the service desk email.   More conditions are better if you can come up with more.



Table: sys_email


Condition:


current.instance.isNil() && gs.now().indexOf(current.sys_created_on)> -1 && current.type == 'received'


Script:


if (current.recipients.indexOf('<servicedeskemail@domain.com>') < 1) {//enter your service desk's email


//service desk email not found in recipients, fire event:


        var evet = new GlideRecord('sysevent');
                evet.initialize();
                evet.process_on = gs.nowDateTime();
                evet.name = "<your event.notification>";//enter your event name
                evet.parm1 = <info to pass to your notification>;//can parse parm1 in the notification.
                evet.insert();


}



Untested and untried, but i think something like this should work.


Many thanks for the responses, will have a look at creating a rule when I


get 5 mins