- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-17-2017 10:38 AM
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
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-17-2017 11:53 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-17-2017 01:13 PM
Thanks again, Sujala!! That worked!
I tweaked it just a small bit to ensure the Caller field was populated and the email attachment body formatted properly. Here are my final edits to Sujala's script for anyone interested.
(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_text;
var sa = new GlideSysAttachment();
current.caller = gs.getUserID();
current.comments = "received from: " + email.origemail + "\n\n" + email.body_text;
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);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-09-2017 10:31 AM
Looks like it's including all images in the email body as attachments, as well. Any way to have it only create the one attachment, from the attachment in the original email?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-01-2017 04:16 PM
I just gave this a quick try and had some success. After the email attachment is created, I can open it in Apple Mail with no issues, but when I open it in Outlook, the message body is missing. Just wondering if you have the same experience. Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-02-2018 08:56 AM
Hi Shea,
I am facing the same issue, did you figure out to fix this?
Thanks,
Vignesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-02-2018 12:22 PM
Sadly, I didn't pursue it all the way through. After getting to this point, I basically validated that it was possible to do this but didn't troubleshoot it all the way to the end.