The CreatorCon Call for Content is officially open! Get started here.

Inbound Action to trim inbound email

Chuck Tomasi
Tera Patron

I'm looking for a way to trim either the activity history on an outbound message or the incoming reply.

Our company is email happy and this has cause some problems. By default, adding ${comments} to a mail notification includes everything. As a result, someone who hits reply, sends all that stuff back and it gets add to the activity history. When an itil person adds a comment to an incident, for example, the notification is now exponentially longer and longer and longer. After a dozen responses back and forth, the activity history becomes useless.

Does anyone have any suggestions how to control these really long tickets (other than telling people to manage their replies better)?

19 REPLIES 19

nikita_mironov
Kilo Guru

To avoid sending the stuff back you might want to control Email Property "For reply emails, discard everything below this text if found in message body (comma separated list, case sensitive)". It is located in System Properties > Email. For example, we are trimming everything that goes after the service-now email address. This posts really the reply but not the original notification.


Thanks Nikita. I think that's getting me in the right direction. I noticed that our Outlook responses don't have the default "Original message". Here's a sample of the end of the reply and the beginning of the sent message:


Website: www.plexus.com<http:>
________________________________
From: Plexus IT Service Desk [plexus@service-now.com]
Sent: Wednesday, December 09, 2009 9:45 AM

I'm thinking we should ignore everything below the line "From: Plexus IT Service Desk [plexus@service-now.com]" or "____________________________\n".

Thoughts?


Valor1
Giga Guru

Try something like this in your action:


var resp = email.body_text.indexOf('From: ');
current.comments = "reply from: " + email.origemail + "\n\n" + email.body_text.substring(0,resp);


Not applicable

Nice job Valor. Here's my script to add some functionality:


var idx = email.body_text.indexOf('IMPORTANT\nThis email');
if (idx == -1) idx = email.body_text.length;
var cmt = email.body_text.substring(0,idx).replace(/\s*$/, "");



In this case, we are searching to strip the disclaimer from all incoming emails form the business, but you could easily strip from a particular message header. The script also handles the entire email if the search text is not found. Finally, a regex strips leading and trailing white space to make a nice, compact Activity history.

If you use the

Create Incident
action, you might also want to strip email prefixes to make a clean Short description.


current.short_description = email.subject.replace(/(FW: |RE: )/g, "");


I love regular expressions http://xkcd.com/208/