Is there a way one can write your own code that stop the popup window when your application attempt to send a mail?

I can use Express ClickYes, but would like to write my own method taking care of this.