How to remove old content from reply emails

Use Case

Customers frequently face the issue of having unnecessary or irrelevant content being added as a comment from a reply email to a particular issue.

It is often the case, that an email gets added as a comment to the issue including long threads of previous messages (e.g.: reply email and the original event notification email to which the reply was sent).

The Email This Issue for Jira app supports the use of regular expressions as a way of separating the latest message from previous ones, and adding only relevant content from a reply email as a comment to the issue.

How to solve this problem

In this section we will showcase two different approaches to remove old content from reply emails, each with their own advantages and disadvantages.

Reactive approach

This is the classical split regex approach which attempts to split the email body based on how various email clients format reply emails.

It is easy to see that mail clients format reply emails differently which makes splitting difficult and prone to errors.

Here are two examples of the two most widely used email clients (Gmail and MS Outlook), th
e red frames mark the expressions people usually try to match when wanting to use regular expressions.

Gmail example:

MS Outlook email example:

MS Outlook regular expression

In the above MS Outlook example the reply is sent to an email that is marked by From: Sent: To: and Subject: text.

We recommend that for multi-language purposes you try using the following regular expression in order to escape the bold formatting as well:
\s*\*From:|___.|On|On .wrote:|----Orig.|On .(JIRA).


Using a reactive approach has many disadvantages:

  • requires complex regular expressions, making it easy to mess up
  • unreliable as the expressions depend on the mail clients
  • high probability of information loss (regex splitting somewhere we don't want to or not splitting the email where we do)

While the only advantage it has is that it does not require modifying your templates.

Proactive approach

This approach attempts to split the email body at a well defined, previously known, unique marker.

Why we recommend using a proactive approach with Email This Issue for Jira:

  • easy to use, requires creating only one regex pattern
  • does not depend on mail clients
  • less probability of information loss
  • visible markers improve customer usability

The proactive approach has two small drawbacks:

  • it requires the use of custom templates in which the markers can be placed
  • due to the need of custom templates, you must implement issue notifications in Jira using Email This Issue for Jira (in case of non-service desk projects)

Step-by-Step Guide

Because of the above mentioned advantages, we highly recommend using a proactive approach with Email This Issue for Jira.

Using any of the below markers will have only the latest email content above the delimiter be added as a comment.

Proactive splitting may be achieved using visible and invisible content markers:

Visible Content Marker

  1. Simply add a delimiter to the top of the body in your email templates, such as adding:

    --Please reply above this line--




  2. Add a regular expression that matches the delimiter in the classic mail handler settings:

    /--Please reply above this line--/



In the next-gen mail handler, the split regex takes Java syntax, therefore please use the below visible delimiter:
--Please reply above this line--

The above marker is just an example, you may use anything you like, just make sure to match the connecting regex to the delimiter.

If the above settings are carried out, the below results are to be expected:

Original email to be cut using a visible content marker:

Comment added to the issue, email cut above the visible content marker:


Invisible Content Marker

HTML Only

The invisible content marker solution only works with HTML emails, but as Email This Issue for Jira supports multiple regular expressions in splitting content, it is possible to add one regex for HTML and one for TEXT emails as well.

Outlook Desktop - Exclusion

As of now, the desktop version of Microsoft Outlook is not compatible with the invisible content marker, however feel free to use it with the web browser version of Outlook.


If you do not want to add a visible and readable content marker as above, you can add an invisible HTML tag editing the HTML code of your email template, and match it in the regular expression.

  1. Add a delimiter to the top of the body in your email templates (in this case the HTML code), such as adding:

    <span title="jeti-reply-marker"></span>




  2. dd a regular expression that matches the delimiter in the classic mail handler settings:

    /\<span title=\"jeti-reply-marker\"\>\<\/span\>/

    In the next-gen mail handler, the split regex takes Java syntax, therefore please use the below invisible delimiter:
    \<span title=\"jeti-reply-marker\"\>\<\/span\>

    We recommend using the <span> tag and the title attribute (the title value can be anything) for a more reliable operation of the regex. Deterring from this practice may result in the mail clients overwriting the value of the tag's attribute.

    If the above settings are carried out, the below results are to be expected:

    Original email to be cut with the HTML source to show the invisible content marker:



    Comment added to the issue, email cut above the invisible content marker: