Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs) ' Get the error details Dim lastErrorWrapper As HttpException = CType(Server.GetLastError(), HttpException) Dim lastError As Exception = lastErrorWrapper If lastErrorWrapper.InnerException IsNot Nothing Then lastError = lastErrorWrapper.InnerException End If Dim lastErrorTypeName As String = lastError.GetType().ToString() Dim lastErrorMessage As String = lastError.Message Dim lastErrorStackTrace As String = lastError.StackTrace Const ToAddress As String = "support@example.com" Const FromAddress As String = "support@example.com" Const Subject As String = "An Error Has Occurred!" ' Create the MailMessage object Dim mm As New MailMessage(FromAddress, ToAddress) mm.Subject = Subject mm.IsBodyHtml = True mm.Priority = MailPriority.High mm.Body = string.Format( _ "" & vbCrLf & _ "
" & vbCrLf & _ "{0} | " & vbCrLf & _ "
{1} | " & vbCrLf & _ "
{2} | " & vbCrLf & _ "
{3} | " & vbCrLf & _ "
{4} | " & vbCrLf & _ "