let me give you some sample code. You don't need to change web.config at all
you want to put this code in your global.asax code behind. This is for C#.Net but you should be able to convert it to VB.Net if thats what you are using
protected void Application_Error(Object src, EventArgs e ){
string emAddr = "developer@yoursite.com"
string trc,message = "Application Error";
Exception objError = Server.GetLastError();
if(objError.InnerException != null)
objError = objError.InnerException;
HttpContext.Current.Application.Add("lastException",objError);
Server.ClearError();
trc = objError.StackTrace.Replace(" at ", "<li>");
trc = trc.Replace(" in ", "<br> ");
message = "<table>"+
"<tr><td colspan=2><b>Application Error</b></td></tr>"+
"<tr><td width=80 valign=top>Source:</td><td>"+ objError.Source + "</td></tr>"+
"<tr><td valign=top>Error:</td><td>"+ objError.Message +"</td></tr>"+
"</table><hr align=center width=80%><table>"+
"<tr><td>Stack Trace:</td></tr>"+
"<tr><td>"+ trc +"</td></tr></table>";
SendEmail(emAddr, "Application Error", message,true);
Server.Transfer("YourErrorPage.aspx");
}
public static void SendEmail(string To, string Subject, string Body, bool HTML) {
System.Web.Mail.MailMessage mail = new System.Web.Mail.MailMessage();
mail.To = To;
mail.From = "whoever@yoursite.com";
mail.Subject = Subject;
mail.Body=Body;
mail.BodyFormat = (HTML?System.Web.Mail.MailFormat.Html:System.Web.Mail.MailFormat.Text);
System.Web.Mail.SmtpMail.SmtpServer = "yourmailserver";
System.Web.Mail.SmtpMail.Send(mail);
}