I'm playing around trying to create a Thunderbird extension, one of the bootstrapped/restartless type (I mean, javascript code is not run from overlays. Instead listeners fire for various events).
At some point I'd like to check the sender and recipients (To, Cc, Bcc) when user decides to send the message, so to perform some checks on them.
I already have a number of event listeners set up and working, including one for compose-send-message
event that gets properly fired when user confirms sending the message.
There, I'm not able to find how to get the sender email address as well as all recipients email addresses. I tried both with:
let fields = components.classes["@mozilla.org/messengercompose/composefields;1"].
createInstance(components.interfaces.nsIMsgCompFields)
and with:
let params = components.classes["@mozilla.org/messengercompose/composeparams;1"].
createInstance(components.interfaces.nsIMsgComposeParams);
let fields = params.composeFields;
but anyway fields.hasRecipients
returns false, and e.g. fields.to
is null (or empty, can't exactly recall). It looks like they're not being set by TB.
Of course I searched around, also in TB threads related to overlays extensions, but with no luck. There's a SO thread here, which does not seem to completely answer the question as it's only about the sender.
Other references: SO again, MozillaZine, TB stdlib.
I've done it even more simply using this.
Well, thanks to the help from people on this mozilla.dev.apps.thunderbird thread and this mozilla.dev.extensions thread, I'm able to access both sender and recipients from within
compose-send-message
event listener.Here's the relevant code... actually, a bit more: the juice is just within
onComposeSendMessage
:Again, thanks all on those groups for feedbacks.