Keith,

Trap the error in the Application_error event. Here is an example in c#

using System.Web.Mail;

protected void Application_Error(Object sender, EventArgs e)
{
        Exception lastError = Server.GetLastError();
        try
        {
                string error = "<h3>An Error Occurred</h3><table><col
style=font-weight:bold;text-align:right /><col />";
                error += "<tr><td>Date/Time of error</td><td>" +
DateTime.Now.ToString() + "</td></tr>";
                error += "<tr><td>Path</td><td>" + Request.Path +
"</td></tr>";
                error += "<tr><td>Machine</td><td>" + Server.MachineName
+ "</td></tr></table>";

                error += "<div
style=background-color:#cccccc;padding:5px><strong>Error
Message</strong></div>";
                error += "<pre>" + lastError.Message + "</pre>";
                error += "<div
style=background-color:#cccccc;padding:5px><strong>Stack
Trace</strong></div>";
                error += "<pre>" + lastError.StackTrace + "</pre>";
                error += "<div
style=background-color:#cccccc;padding:5px><strong>Exception</strong></d
iv>";
                error += "<pre>" + lastError.InnerException.ToString() +
"</pre>";
                error += "<div
style=background-color:#cccccc;padding:5px><strong>Source</strong></div>
";
                error += "<pre>" + lastError.Source + "</pre>";
                error += "<div
style=background-color:#cccccc;padding:5px><strong>Server
Variables</strong></div>";
                error +=
EnumHttpCollectionToTable(Request.ServerVariables);
                error += "<div
style=background-color:#cccccc;padding:5px><strong>Form</strong></div>";
                error += EnumHttpCollectionToTable(Request.Form);
                error += "<div
style=background-color:#cccccc;padding:5px><strong>QueryString</strong><
/div>";
                error += EnumHttpCollectionToTable(Request.QueryString);

                MailMessage email = new MailMessage();
                email.To = <your email>;
                email.From = <from email>;
                email.Subject = "Error";
                email.BodyFormat = MailFormat.Html;
                email.Body = error;
                SmtpMail.SmtpServer = <your mail server>;
                SmtpMail.Send(email);
        }
        catch{}
        EventLog ev = new EventLog();
        ev.Log = "Application";
        ev.Source = Request.ServerVariables["SERVER_NAME"];
        ev.WriteEntry(lastError.InnerException.ToString(),
EventLogEntryType.Warning);
}       

-----Original Message-----
From: Keith Turgeon [mailto:[EMAIL PROTECTED]] 
Sent: Monday, September 30, 2002 1:40 PM
To: dotnet
Subject: Email trace results automatically?


Good Afternoon,

Is there a way (VB.NET) to to setup an application so that when a 500
error gets thrown, an email is fired off to the administrator with all
of the information that is available in the page trace?  

Any ideas?

Thanks!
Keith



---
You are currently subscribed to dotnet as: [EMAIL PROTECTED]
To unsubscribe send a blank email to
%%email.unsub%%

---------
Administrated by 15 Seconds : http://www.15Seconds.com
List Archives/Search : http://local.15Seconds.com/search Subscription
Information : http://www.15seconds.com/listserv.htm
Advertising Information: http://www.internet.com/mediakit/



---
You are currently subscribed to dotnet as: [email protected]
To unsubscribe send a blank email to [EMAIL PROTECTED]

---------
Administrated by 15 Seconds : http://www.15Seconds.com
List Archives/Search : http://local.15Seconds.com/search
Subscription Information : http://www.15seconds.com/listserv.htm
Advertising Information: http://www.internet.com/mediakit/


Reply via email to