I have recently set up some email to salesforce functionality.

However email to salesforce also logs all of the replies from the email, so after a few replies, the task contents become rather lengthy/large to read.

Is there any way to set up something using salesforce or apex to remove the replies so my task only contains the latest message sent?


When I had that issue in the past, I created a trigger on the EmailMessage object that stripped off what appeared to be replies using regular expressions and then added a formatted comment to the case with the data (I wrote back around 2008 or 2009, so is a bit old..). I can try to find it if you would like to look


You could write an after insert trigger on task which will verify status = Inbound Email and Related To = Object's Id which is used for email responses.

Then based on Thread Id (which is available on Subject), status, related to Ids and timestamps you could pickup other tasks and remove those except the latest one.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.