Properly encode htmlchars in thread bodies

And avoid double encoding email bodies if html thread is not enabled