thysmichels.com
Generating an Email-to-Case thread id using Apex
How to generate Email-to-Case thread id inside template: Generate the thread Id Send customEmail and Add ThreadId Putting it all together