Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

When ever we will send mail from outlook to ServiceNow this mail need to add as a attachment inINC .

Venkata Subbam1
Tera Contributor

Hello all ,

Requirement : When ever we will send mail from outlook to ServiceNow below activities need to perform .

 1. This mail need to be attached as a "Attachment" to the particular closed incident 

  2.  Mail body content need to updated in the work notes for that incident .

Could any one please suggest  me the solution for this requirement .

 

Thanks!

 

Regards,

Venkata

1 ACCEPTED SOLUTION

siva krishna M2
Tera Guru

Hello @Venkata Subbam1 ,

 

Create an inbound email action with Target table as "incident" and Action type as "Record Action" with below script under Actions tab

 

(function runAction(/*GlideRecord*/ current, /*GlideRecord*/ event, /*EmailWrapper*/ email, /*ScopedEmailLogger*/ logger, /*EmailClassifier*/ classifier) {
 
var emailcontent= "Subject"+email.subject+"\n\n"+"From: "+email.origemail+"\n"+"To:"+email.to+"\n"+"\n\n\n"+email.body_text;
// Implement email action here
var p = new GlideRecord('incident');
p.get(current.sys_id)
var k = new GlideSysAttachment();
k.write(p,"email_attachment.txt","text/html",emailcontent)
current.work_notes = email.body_text;
current.update();
 
})(current, event, email, logger, classifier);
 
                                                                       (or)
 
If you want the attachment in email format then you can use below code inside the function
 
var emailcontent= email.content_type+"\n"+email.headers+"\n\n"+email.body_text;
// Implement email action here
var p = new GlideRecord('incident');
p.get(current.sys_id)
var k = new GlideSysAttachment();
k.write(p,"emailattachment.eml","application/octet-stream",emailcontent)
current.work_notes = email.body_text;
current.update();
 
 

 

If it helps, Kindly click on "Helpful" and mark it as Accepted solution

View solution in original post

6 REPLIES 6

Pranav_Thanedar
Mega Sage

@Venkata Subbam1 

 

For your 1st question:

 

1. You can use flow Designer to process the inbound email.

2. Use the flow designer to generate a file.

3. Copy your inbound email content to the file.

4. Attach that email as attachment to the incident.

 

There is a article written for this - https://community.servicenow.com/community?id=community_article&sys_id=1fb58dbbdb74d9102dc24f7813961... as there is no OOB way to generate a file.

 

For the 2nd question:

 

You can simply use the trigger inbound email data pill to get body of that email and update the worknotes.

 

Pranav_Thanedar_0-1707198164679.png

 

 

 

If you feel this has helped you a bit, you may mark the answer as helpful or accept it as a solution.

 

Regards,

Pranav Thanedar

siva krishna M2
Tera Guru

Hello @Venkata Subbam1 ,

 

Create an inbound email action with Target table as "incident" and Action type as "Record Action" with below script under Actions tab

 

(function runAction(/*GlideRecord*/ current, /*GlideRecord*/ event, /*EmailWrapper*/ email, /*ScopedEmailLogger*/ logger, /*EmailClassifier*/ classifier) {
 
var emailcontent= "Subject"+email.subject+"\n\n"+"From: "+email.origemail+"\n"+"To:"+email.to+"\n"+"\n\n\n"+email.body_text;
// Implement email action here
var p = new GlideRecord('incident');
p.get(current.sys_id)
var k = new GlideSysAttachment();
k.write(p,"email_attachment.txt","text/html",emailcontent)
current.work_notes = email.body_text;
current.update();
 
})(current, event, email, logger, classifier);
 
                                                                       (or)
 
If you want the attachment in email format then you can use below code inside the function
 
var emailcontent= email.content_type+"\n"+email.headers+"\n\n"+email.body_text;
// Implement email action here
var p = new GlideRecord('incident');
p.get(current.sys_id)
var k = new GlideSysAttachment();
k.write(p,"emailattachment.eml","application/octet-stream",emailcontent)
current.work_notes = email.body_text;
current.update();
 
 

 

If it helps, Kindly click on "Helpful" and mark it as Accepted solution

Hi Siva Krishana,

Thank you for your response,

I have used your script and when ever i am trying to test it email body is coming to sys_email table but in incident form no work notes are updated. And sys_email table target is showing like empty .

Please help to achieve this requirement. 

 

Thanks!

Regards,

Venkata.

 

Hello @Venkata Subbam1 ,

 

Please share the email logs and also check whether any flow or inbound action stops processing other inbound actions