i need some help if possible. I developing an addon which adds an extra StringReference header to a letter during send.
After it is in the "Sent" folder I would like to collect threadId (this is ok), and remove the extra StringReference from the header. I have found the following http://mdn.beonex.com/en/XPCOM_Interface_Reference/nsIMsgDBHdr.html:
In clear, if you want to do a persistent change to a message header, such as marking it as read, or replied to, or whatever, you MUST do it through its corresponding nsIMsgFolder (msgHdr.folder) or nsIMsgDatabase (msgHdr.folder.msgDatabase).
But I cannot make a working code, because I cannot get nsIMsgDatabase, but even if I could have this object for the actual msgHdrDb I should call Commit(type) with some commit type I cannot figure out. Could anyone help me with some example how to make permanent changes on a message in the msgHdrDb?
Thank you for you help in advance!
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,