I'm pretty sure this method does not work, as you'll be only modifying the locally-stored message header, not the actual message. While this works fine for local folders / POP3 accounts, it won't work for IMAP accounts, and the changes won't be propagated to the IMAP server.
There's actually a thread about this at https://groups.google.com/forum/#!topic/mozilla.dev.apps.thunderbird/yWGIYQ8bwfE ; it contains a lot of valuable information, and answers your question. You basically have to create a new copy of the message and inject it into the folder. Doing that, you can modify the headers. I think the bottom line is: just look at the source code of https://addons.mozilla.org/thunderbird/addon/header-tools-lite/?src=mozilla.dev.apps.thunderbird (header tools lite) to see how they do it.
Cheers,