views:

113

answers:

0

I am working on a very simple Thunderbird extension, which is supposed to alert the name of the sender along with the names of the recipients whenever a mail is sent. The problem is that gMsgCompose.compFields.from field is empty in the below snippet (the .to field works as expected), which handles the "compose-send-message" event. What am I missing here?

function send_event_handler( evt ) {
var msgcomposeWindow = document.getElementById( "msgcomposeWindow" );
var msg_type = msgcomposeWindow.getAttribute( "msgtype" );

// do not continue unless this is an actual send event
if( !(msg_type == nsIMsgCompDeliverMode.Now || msg_type == nsIMsgCompDeliverMode.Later) )
  return;

var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService(Components.interfaces.nsIPromptService);
promptService.alert(window, "From", gMsgCompose.compFields.from);
promptService.alert(window, "To", gMsgCompose.compFields.to);
}

window.addEventListener( "compose-send-message", send_event_handler, true );