void Application_Error(object sender, EventArgs e) { // Get the error details HttpException lastErrorWrapper = Server.GetLastError() as HttpException; Exception lastError = lastErrorWrapper; if (lastErrorWrapper.InnerException != null) lastError = lastErrorWrapper.InnerException; string lastErrorTypeName = lastError.GetType().ToString(); string lastErrorMessage = lastError.Message; string lastErrorStackTrace = lastError.StackTrace; const string ToAddress = "support@example.com"; const string FromAddress = "support@example.com"; const string Subject = "An Error Has Occurred!"; // Create the MailMessage object MailMessage mm = new MailMessage(FromAddress, ToAddress); mm.Subject = Subject; mm.IsBodyHtml = true; mm.Priority = MailPriority.High; mm.Body = string.Format(@"
{0} |
{1} |
{2} |
{3} |
{4} |