Currently I'm working on something that needs to recognize threads from email conversations. An easy way would be to rely on a specific token/reference being present in the Subject. However to allow users to change email subjects without losing track of the "thread", we need to rely on using email headers, specifically: message-id, in-reply-to and references.
These headers are best described in RFC 2822 (Section 3.6.4)
Another interesting link that discusses how emails work: Reading Email Headers