- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-31-2023 11:31 AM
Hi All,
I have a record on the sys_email table whenever an email is sent from the tool to the servicenow. These records have the body of mail in HTML format. When I right-click on it and click preview mail, then it shows me the whole proper body of the mail. I want to attach this mail body whole in the Work notes of the incident. Basically, I have written an inbound email action that creates an incident as soon as the XML format mail is received in the sys_email table. On the same new incident, the mail (which was seen when clicked on the preview email) should be attached to the incident work note.
Can anyone help me with this?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-06-2023 02:49 AM
Hi @swapnil15
Let's have a look into the post below.
Save Email Text as Attachment
make sure to replace the function createAttachment as following Scott20's comment.
function createAttachment(emailRec, currentRec) {
var fileName = emailRec.subject + '.eml';
// Setup array to push email values into. Add additional as needed/
var emailData = [];
emailData.push("To: " + emailRec.to);
emailData.push("Subject: " + emailRec.subject);
emailData.push("From: " + emailRec.origemail);
emailData.push("Headers: " + emailRec.headers + "Content-Type: multipart/mixed");
emailData.push("");
emailData.push("<html>");
emailData.push("<body>");
emailData.push(emailRec.body_html);
emailData.push("</body>");
emailData.push("</html>");
// Convert emailData to a string separated by new line character.
var emailString = emailData.join(this.newLineChar);
// Create attachment with email string and attach it to the record creatd by the email.
var sysAttachment = new GlideSysAttachment();
sysAttachment.write(currentRec, fileName, this.contentType, emailString);
}
Cheers,
Tai Vu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-11-2023 06:02 AM
I have the same requirement but we need data in html format in pdf.
I tried below code but it didn't work..