Can the email for Inbound Email Action be attached to the incident record?

Dlam
Tera Expert

We would like to automate the creation of an incident record when an alert email is sent to our service desk. I have achieved it by either an Inbound Email Action or a flow.

 

However, is it possible to have the actual email to be attached to the incident record as an attachment? The email body text does get pre-populated in the Description but it will be even better if the email itself can be attached as it contains image and the html format look better.

 

In addition, can anyone confirm if the From condition is no longer available in When to run when setting up the Inbound Email Action? I could not find the From in Fields list in Flow designer either. I was not able to configure the actions to be triggered by an email from a particular email address.

 

Much appreciate any input.

1 ACCEPTED SOLUTION

Sohail Khilji
Kilo Patron
Kilo Patron

Hi @Dlam ,

 

Here is one way to copy email as attachement to inbound record:

In the var content use email.body_text. If you use email.body you will not see the output.

  var attachment = new GlideSysAttachment();
   var fileName = email.subject + '.eml';
   var contentType = 'application/octet-stream';
   var content = email.content_type + "\n" + email.headers + "\n\n\n\n" + email.body_text;

   attachment.write(current, fileName, contentType, content);

   current.insert();

 

 video: https://www.youtube.com/watch?v=KZpZDqbRKU4

 

How to copy the attachments via Inbound email action into Servicenow Incident table?

var sysAttach = new GlideSysAttachment();   
var emailSysId = sys_email.getUniqueValue(); 
gs.log("Email sys_id is: " + emailSysId, "TITUS");

if (emailSysId) { 
   var sysEmailAttachments = sysAttach.getAttachments("sys_email", emailSysId); 
   gs.log("Number of attachments found: " + sysEmailAttachments.getRowCount(), "TITUS");
   gs.log("Updating attachments to table: " + current.getTableName() + " and sys_id: " + current.getUniqueValue(), "TITUS");
   while (sysEmailAttachments.next()) { 
         sysEmailAttachments.setValue("table_name", current.getTableName()); 
         sysEmailAttachments.setValue("table_sys_id", current.getUniqueValue()); 
         sysEmailAttachments.update(); 
   } 
} 

 


☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....

LinkedIn - Lets Connect

View solution in original post

In this video, you'll learn how to process an inbound email with Flow Designer and update an existing record. Flow Designer: https://docs.servicenow.com/bundle/rome-servicenow-platform/page/administer/flow-designer/concept/flow-designer.html Flow Trigger Types: ...
4 REPLIES 4

Mahathi
Mega Sage
Mega Sage

Hi @Dlam ,

We do not have an out of box flow to do it but we have someone who has already done this.

Please refer to: 

https://www.servicenow.com/community/developer-articles/generate-an-attachment-via-custom-flow-desig...

Please mark helpful and accept as solution if this helped answer your query.

Thanks,
Mahathi

Mahathi
Mega Sage
Mega Sage

Mahathi_0-1717580341570.png

 

We still have the From option in when to run in the Inbound actions if this is what you are looking for.

Please mark helpful and accept as solution if this helped answer your query.

Thanks,
Mahathi

Thank you. Yes, I see it now. 

Sohail Khilji
Kilo Patron
Kilo Patron

Hi @Dlam ,

 

Here is one way to copy email as attachement to inbound record:

In the var content use email.body_text. If you use email.body you will not see the output.

  var attachment = new GlideSysAttachment();
   var fileName = email.subject + '.eml';
   var contentType = 'application/octet-stream';
   var content = email.content_type + "\n" + email.headers + "\n\n\n\n" + email.body_text;

   attachment.write(current, fileName, contentType, content);

   current.insert();

 

 video: https://www.youtube.com/watch?v=KZpZDqbRKU4

 

How to copy the attachments via Inbound email action into Servicenow Incident table?

var sysAttach = new GlideSysAttachment();   
var emailSysId = sys_email.getUniqueValue(); 
gs.log("Email sys_id is: " + emailSysId, "TITUS");

if (emailSysId) { 
   var sysEmailAttachments = sysAttach.getAttachments("sys_email", emailSysId); 
   gs.log("Number of attachments found: " + sysEmailAttachments.getRowCount(), "TITUS");
   gs.log("Updating attachments to table: " + current.getTableName() + " and sys_id: " + current.getUniqueValue(), "TITUS");
   while (sysEmailAttachments.next()) { 
         sysEmailAttachments.setValue("table_name", current.getTableName()); 
         sysEmailAttachments.setValue("table_sys_id", current.getUniqueValue()); 
         sysEmailAttachments.update(); 
   } 
} 

 


☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....

LinkedIn - Lets Connect

In this video, you'll learn how to process an inbound email with Flow Designer and update an existing record. Flow Designer: https://docs.servicenow.com/bundle/rome-servicenow-platform/page/administer/flow-designer/concept/flow-designer.html Flow Trigger Types: ...