Inbound Email - Has attachment

athavichith
Kilo Sage

Hi Community,

 

Is there a way to check if an inbound email has attachment? I am using this script to check attachment:

 

    // Implement email action here
    // Check if the inbound email has attachments
    var attachments = email.attachments;

    if (attachments && attachments.size() > 0) {
        //gs.info("Inbound Email has " + attachments.size() + " attachment(s). Creating HR ticket...");
2 REPLIES 2

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @athavichith 

https://www.servicenow.com/community/developer-forum/checking-if-an-inbound-email-has-an-attachment/...

 

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

swapnali ombale
Kilo Sage

Hi @athavichith 

 

var email_log = new GlideRecord('sys_email');
email_log.addQuery('uid', email.uid);
email_log.query();

if (email_log.hasNext()) {
email_log.next();
var hasAttachments = email_log.has_attachments; // Check if the email has attachments
if (hasAttachments) {
// Handle the case where the email has attachments
// For example, you might want to attach the attachments to a related record.
} else {
// Handle the case where the email does not have attachments.
}
}

 

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