Add the original email message as attachment to incident record

sbanc
Kilo Guru

Hi Everyone

I have a need for having the original, untouched email message from the inbound email action added as .msg or .eml to the inserted incident record.

I already searched the community but only found a way to add a HTML file to the record with the email body in it.

We need this, that our ITIL users can reply to the origin email with all the header details ect. of the original inbound email.

Does anyone have an idea to get this working?

By the way, I am not familiar with the attachmentcreator, since my coding know-how isn't on a high level.

Thank you in advance for any input!

Regards,

Simon

1 ACCEPTED SOLUTION

adrianherdan
Kilo Expert

Hello,

I've got a better solution for you if you like. A link that will show you the email along with pictures in a modal in the incident. Hope this helps!

Create a new UI Action on the Incident Table with the following code:

 

function clickPreview() {
// the following is what we have to do to make this client
// script work from a list and form, with today's code
var sysId = typeof rowSysId == 'undefined' ? gel('sys_uniqueValue').value : rowSysId;

var msg = getMessage("Preview Email");
var gr = new GlideRecord("sys_email");
gr.addQuery("instance", sysId);
gr.addQuery("mailbox", 'received');
gr.query();
if (gr.next()) {
var dd = new GlideModal("preview_email");
dd.setTitle(msg);
dd.setWidth(800);
dd.setPreference('sysparm_id', gr.sys_id);
dd.render();
} else {
alert("Email not found: " + sysId);
}
}

 

 

find_real_file.png

View solution in original post

5 REPLIES 5

henry_cheng
ServiceNow Employee
ServiceNow Employee

Hi Simon,



AFAIK there is no existing function that can attach the original email into the created incident record.


As you figured out already you can create a business rule and copy the email body or any other information from the email into the incident record.


However to attach the original email this is a heavy customization to create a new .msg file exactly the same as the original email being sent out.



Regarding attachmentcreator this is a SOAP WebService. It has been replaced by the latest Attachment API. Please refer to below wiki page.


AttachmentCreator SOAP web service


You can use it to create attachment on any table records. But return to your question the key thing is how to create a *.msg file as an attachment based on the information in the sys_email table records. I reckon this needs to involve Microsoft as well to know the .msg file structure, it is not a simple customization.



Cheers


Henry


adrianherdan
Kilo Expert

Hello,

I've got a better solution for you if you like. A link that will show you the email along with pictures in a modal in the incident. Hope this helps!

Create a new UI Action on the Incident Table with the following code:

 

function clickPreview() {
// the following is what we have to do to make this client
// script work from a list and form, with today's code
var sysId = typeof rowSysId == 'undefined' ? gel('sys_uniqueValue').value : rowSysId;

var msg = getMessage("Preview Email");
var gr = new GlideRecord("sys_email");
gr.addQuery("instance", sysId);
gr.addQuery("mailbox", 'received');
gr.query();
if (gr.next()) {
var dd = new GlideModal("preview_email");
dd.setTitle(msg);
dd.setWidth(800);
dd.setPreference('sysparm_id', gr.sys_id);
dd.render();
} else {
alert("Email not found: " + sysId);
}
}

 

 

find_real_file.png

Hi Adrian

Thank you for this function. Anyway, this would not fit my needs at all. We decided with the business that we can't give them this ability to answer to original emails with ServiceNow.

Cheers
Simon

 

Thanks, this works great.