Here’s my problem I have some code and I’m using it to send an e-mail with the last error details but all I want is the (Inner)Exception Message to be displayed in the email with the URL
Here’s my code
Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
' Get current exception
Dim err As System.Exception = Server.GetLastError
Dim ErrorDetails As String = err.Exception.Message
Dim ErrorURL As String = Request.Url.ToString()
' Send notification e-mail
Dim Email As MailMessage = _
New MailMessage("email@email.co.uk", email@email.co.uk")
Email.IsBodyHtml = False
Email.Subject = "WEB SITE ERROR"
Email.Body = ErrorDetails & vbcrlf & vbcrlf & ErrorURL
Email.Priority = MailPriority.High
Dim sc As SmtpClient = New SmtpClient("localhost")
sc.Send(Email)
End Sub
Any help would be much appreciated
Thanks
Jamie
Use
err.ToString()– this gives you the full strack trace and inner exceptions.If you really only want the inner exception error message, use
err.InnerException.Message