Ignore specific images in inbound emails

Vejdis
Tera Expert

Hello!

We have some email notifications, for example when a new incident is created.

These notifications contains some images, such as banner with a logo etc.

 

When a user replies the images gets added to the ticket. Can we ignore theese specific images somehow?

 

I have researched the bytes filtering (sys_property: glide.email.inbound.image_sys_attachment.filter.minimum_bytes) but this would block images we are after aswell.

 

I have also looked into the exchange side of things but they require a specific name and when a user responds on the mail the images are always named image00X instead of their proper names.

 

Has anyone ran into this problem and found a solution, more than just remove all images

2 REPLIES 2

Community Alums
Not applicable

Hi,

 

Have you tried writing some inbound email scripts to remove attachments like banner and logo when user replies

example code:

(function processEmail(email, email_script, event) {
var imageNamesToIgnore = ['banner.png', 'logo.jpg']; // Add the specific image names to ignore as you want

var attachments = email.getAttachments();
for (var i = 0; i < attachments.size(); i++) {
var attachment = attachments.get(i);
var attachmentName = attachment.getFileName();

if (imageNamesToIgnore.indexOf(attachmentName) !== -1) {
email.removeAttachment(i);
i--; // Decrement the index to account for the removed attachment
}
}

event.state = "stop_processing";
})(email, email_script, event);

 

But the above script will work if the passed images name are constant. if they are dynamically changing it will not work

 

thanks 

Sravani

Hi!

This would work, if I could count on the names being as they are... but most of the times the images appear as image00X.png

 

Do you know how to make sure that images that arrive in servicenow keeps their original names? If that was the case then this would be a great solution!

 

I do find it weird with the names since we do send out some images in our notifications, and in some tickets where the users reply the names are kept as they are in our servicenow instance such as Logo.png. But most of the times it's just image00X.png and I can't find where the issue comes from