Forward an email to JIRA as the sender on JEMH Server

A customer (john@customer.com) sends an email an employee (joe@mycompany.com) instead of the JEMHC's JIRA mail box (support@mycompany.com). The employee would like to tackle the use case via JIRA rather than a standard email conversation with the customer. So the employee could reply/forward the email to both the customer (john@customer.com) with copy to JEMHC mail box (support@mycompany.com). There are a few problems with this approach.

  1. The employee will be the reporter/sender of the email instead of the customer. 

  2. The employee may not want to be involved, he wants the ticket in the JIRA queue so the ticket is handled by the team.

  3. The employee needs to send the forwarded email back to the customer so customer address doesn't get lost. If this email is replied, the conversation will be out of JIRA.

  4. The user may also receive a JEMHC email from the created ticket but not as the reporter/sender of the email.

  5. The original reply could be stripped out so forward should be used.

A forwarded email from Gmail looks like the following:

Gmail Forwarded Email

MIME-Version: 1.0 Received: by 10.157.39.45 with HTTP; Mon, 2 Jan 2017 18:24:15 -0800 (PST) In-Reply-To: <CAM05jUm7ChfoFW_AM8RCsODW_hL8cpyT4LrNvPDL1GjoxJ6tFg@mail.gmail.com> References: <CAM05jUm7ChfoFW_AM8RCsODW_hL8cpyT4LrNvPDL1GjoxJ6tFg@mail.gmail.com> Date: Mon, 2 Jan 2017 23:24:15 -0300 Subject: Fwd: I have a problem From: Joe Company <joe@mycompany.com> To: Support <support@mycompany.com> Content-Type: text/plain; charset=UTF-8 Message-ID: <CAJQE=NOijOO4=89Scau3RZZgHWB19q=C+tnBfaLK6F1wp3v0FQ@mail.gmail.com> ---------- Forwarded message ---------- From: John Customer <john@customer.com> Date: Mon, Jan 2, 2017 at 11:23 PM Subject: I have a problem To: Joe Company <joe@mycompany.com> Hi Joe, my name is John and I have this problem....



In JEMHC, one of the features provided is to Create a Pre-Procssing Task (velocity script). However, there might be some users wishing this feature on JEMH Server version. 

This can be achieved by using a Script Field Processor and implementing the following script:

var subjectPrefix = ["Fwd:","Fw:","WG:","Doorst:","VL:","TR:","I:","FS:","VS:","VB:","RV:","PD"]; var regex = /From: (.*)<(.*)>/; var found = body.match(regex); for(var i = 0; i < subjectPrefix.length; i++){ if(subject.contains(subjectPrefix[i])){ print(subject); print("Match found on: " + subjectPrefix[i]); var sender = fromAddress.getAddress(); if(sender.toLowerCase().contains("@mycompany.com")){ print("Sender is from my company"); if(found.length === 3){ var originalSender = found[2]; print("Original Sender: "+ originalSender); resultMap.put("reporter", originalSender); } } } }

Few aspects to take into account:

  • Ensure the original sender has the permission to create issues as they are going to become the reporter

  • Any different subject prefixes should be accounted for (different language)

  • In this example, we are using the Regex which matches against From: Mark Handle <Mark_handle@testing.com>; therefore, any change in this format will need to result in update of the Regex accordingly.