There are two pre-existing questions on the site. One for Python, one for Java.
Possibly helpful: quotequail is a Python library that helps identify quoted text in emails