I am working on writing an add-on for Thunderbird and would like to be able to cancel the sending of an email under certain conditions. I have the following code which allows me to execute code before the email is sent, but I don't know how to stop it.
document.getElementById("msgcomposeWindow").addEventListener( "compose-send-message", function(){
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;
alert('Sending Message...');//works fine
if(true){ //eventually this would have more logic...
//stop email
}else{
//let email go
}
}, true );
What do I need to do to stop the email?