- 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 11:29 AM
try this ..
var strEmailContent = email.content_type +"\n"+ email.headers + "\n\n\n\n"+ email.body;
var sa = new GlideSysAttachment();
var cr = new GlideRecord('new_call');
cr.initialize();
cr.short_description = email.subject;
cr.description =email.body_text;
// map fields that are mandatory or necessary'
sa.write(cr, email.subject +".eml", " application/octet-stream ", strEmailContent);
cr.insert();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2017 11:36 AM
Thank you, Sujala! Unfortunately, when testing this script I discovered this actually just creates an additional Call record with the email details instead of adding the .eml file that generated the Call record as an attachment.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2017 01:09 AM
Does this works for creating PDF as well?
Regards
Deepak
- 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.