Inbound Email as Attachment on Call Record

nathanjulo43
Kilo Contributor

Hello!

In our instance (Helsinki), we currently have inbound emails generating Call records for our Service Desk to work and determine the appropriate path (Incident, Request, etc.).

On this inbound email action, I have attempted to add a script under the Action tab to attach the inbound email(.eml) to the Call record as an attachment. This is useful for our environment because in many situations the customer will cc others already working on, or have worked on in the past, whatever they are reporting or requesting. The Service Desk can view that original email and get a quick understanding of the escalation path for that record.

I am honestly a novice at scripting and I pull most of my scripts from the rock stars around this community! Do any of you have a few moments to take a look at the script below to let me know if I am completely out in left field with what I have up to this point?

var strEmailContent = email.content_type +"\n"+ email.headers;

        strEmailContent += "\n\n\n\n"+ email.body;

var sa = new GlideSysAttachment();

        sa.write(current, strFileName +".eml", " application/octet-stream ", strEmailContent);

Thank you so much for your time!

Nathan

1 ACCEPTED SOLUTION

sujalavemula
Kilo Guru

try this .It works for me .. it should work for you too



(function runAction(/*GlideRecord*/ current, /*GlideRecord*/ event, /*EmailWrapper*/ email, /*ScopedEmailLogger*/ logger, /*EmailClassifier*/ classifier) {




  // Implement email action here


  var strEmailContent = email.content_type +"\n"+ email.headers + "\n\n\n\n"+ email.body;


var sa = new GlideSysAttachment();




current.short_description = email.subject;


current.description =email.body_text;


// map fields that are mandatory or necessary'


sa.write(current, email.subject +".eml", " application/octet-stream ", strEmailContent);




current.insert();




})(current, event, email, logger, classifier);





hope this helps.


View solution in original post

14 REPLIES 14

vondes
Kilo Contributor

Can we use it together with mobile-phone-tracker.org mobile recorder on Android?


Gerry Crumbley
Giga Expert

I've tried this, but can't get it to work. I don't get any Email Body with it. This is the .eml attachment in the INC:

find_real_file.png

Here is the script:

// Note: current.opened_by is already set to the first UserID that matches the From: email address

(function runAction(/*GlideRecord*/ current, /*GlideRecord*/ event, /*EmailWrapper*/ email, /*ScopedEmailLogger*/ logger, /*EmailClassifier*/ classifier) {
// Implement email action here
var strEmailContent = email.content_type +"\n"+ email.headers + "\n\n\n\n"+ email.body;
var sa = new GlideSysAttachment();

current.caller_id = gs.getUserID();
current.comments = "forwarded by: " + email.origemail + "\n\n" + email.body_text;
current.short_description = email.subject;

current.category = "O365";
current.incident_state = IncidentState.NEW;
current.notify = 2;
current.contact_type = "email";

if (email.body.assign != undefined)
current.assigned_to = email.body.assign;

if (email.body.priority != undefined)
current.priority = email.body.priority;

// map fields that are mandatory or necessary'
sa.write(current, email.subject +".eml", " application/octet-stream ", strEmailContent);

current.insert();

})(current, event, email, logger, classifier);

 

Can someone tell me where the error is?

Hi Gerry,

 

I am facing the same issue. Were you able to fix this?

Regards,

Surabhi

Missing the '_text' when setting the strEmailContent 

// Note: current.opened_by is already set to the first UserID that matches the From: email address

(function runAction(/*GlideRecord*/ current, /*GlideRecord*/ event, /*EmailWrapper*/ email, /*ScopedEmailLogger*/ logger, /*EmailClassifier*/ classifier) {
// Implement email action here
var strEmailContent = email.content_type +"\n"+ email.headers + "\n\n\n\n"+ email.body;
var sa = new GlideSysAttachment();

current.caller_id = gs.getUserID();
current.comments = "forwarded by: " + email.origemail + "\n\n" + email.body_text;
current.short_description = email.subject;

current.category = "O365";
current.incident_state = IncidentState.NEW;
current.notify = 2;
current.contact_type = "email";

if (email.body.assign != undefined)
current.assigned_to = email.body.assign;

if (email.body.priority != undefined)
current.priority = email.body.priority;

// map fields that are mandatory or necessary'
sa.write(current, email.subject +".eml", " application/octet-stream ", strEmailContent);

current.insert();

})(current, event, email, logger, classifier);

I'm still facing the same issue. PFA for the sample email attachment. I used this code also. Kindly anyone has workaround for this.

 

Regards,

Harini

 

HariniDhanapal_1-1704791476556.png