Attaching inbound email to ticket in .msg format

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-19-2017 06:53 PM
We would like to attach the actual original email that is sent to our instance to the created ticket - the best we have been able to do so far is attach the source email in plain text .eml format. Does anyone have a similar requirement or have been able to achieve the outcome?
Here is the script we're using:
/**
* This creates an converts the email to be an attachment on the record passed in
* At the moment it only works with Plain text - as I could not get it working otherwise!
* To use this in an inbound email, use the following code.
*
* var emailUtilsObj = new APIEmailUtilities();
* emailUtilsObj.makeEmailAsAttachment(email, current);
*
* @param {Object} _emailObj - The sys_email object used in bound actions
* @param {GlideRecord} _currentRec - The record we want to attach this to.
*
* @return {nothing}
*/
APIEmailUtilities.prototype.makeEmailAsAttachment = function(_emailObj, _currentRec) {
var sysAttachObj = new GlideSysAttachment();
//Make the file name - needs to be text/plain or won't work.
var fileNameStr = String(_emailObj.subject) + '.eml';
var contentTypeStr = 'text/plain';
var emailStr = '';
emailStr += 'To: ' + _emailObj.to + '\n';
emailStr += 'Subject: Re: ' + _emailObj.subject + '\n';
emailStr += 'From: ' + _emailObj.origemail + '\n';
emailStr += 'Reply-To: ' + _emailObj.origemail + '\n';
emailStr += _emailObj.body_text;
//Attach the email to the current record.
var sysIdNewAttachment = sysAttachObj.write(_currentRec, fileNameStr, contentTypeStr, emailStr);
};
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-03-2019 08:57 PM
Hey Warren,
I've added an update to Michael's Post, I believe I got it to work correctly with the body_html, rather than plain text.
Have a look if its still something you are interested in.
Thanks,
Scott