When the previous emails are stored on the disk, or available somwhow, you could check all mails, send by a specific receiver to determine, which is the response text.
You also could try to determine the quote character, by checking the first character of the last lines. Normaly the last lines always start with the same character.
When the last 2 lines starting with a ifferent character, youcould try the first lines, because sometimes the answer is appended atthe end of the text.
If you have detected these character, you could delete the last lines which are starting with this character until a empty line or a line starting with another character is detected.
NOT TESTED and is more like pseudo code
String[] lines;
// Check the size of the array first, length > 2
char startingChar = lines[lines.length - 1].charAt(0);
int foundCounter = 0;
for (int i = lines.length - 2; i >=0; --i) {
String line = lines[i];
// Check line size > 0
if(startingChar == line.charAt(0)){
++foundCounter;
}
}
final int YOUR_DECISION = 2; // You can decide
if(foundCounter > YOUR_DECISION){
deleteLastLinesHere(startingChar, foundCounter);
}