How can I configure my email template to include the most recent email for a case but NOT all emails logged in the case?

My understanding is that {!Case.Email_Thread} just collects all of the emails in the "email" section and puts them in chronological order.

Essentially I'm looking for the equivalent of {!Case.Last_Case_Comment} but for emails.

The Reply link won't help me because it doesn't include the other stuff my template does.

1 Answer 1


Query the EmailMessage Object

[Select ID From EmailMessage Where Case ID = :THECASEID ORDER BY MessageDate DESC LIMIT 1];

You will need to bulkify if this approach meets your needs

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .