Currently we are setting up a customs error page in our site. When an error occurs, the user is directed to the custom error page and an email is fired off from global.asax as to what occured with the compiler throug the following code:
Protected Sub Application_Error(ByVal Sender as Object, ByVal e as EventArgs)
Dim ErrorDescription As Exception = Server.GetLastError
Dim url As String
Dim body As String
If Not (ErrorDescription Is Nothing) Then
ErrorDescription = ErrorDescription.InnerException
'Build My message body
body = "<b>Error Message:</b><br>" & ErrorDescription.Message & _
"<br><br><b>Error Source:</b><br>" & ErrorDescription.Source & _
"<br><br><b>Error Type:</b><br>" & ErrorDescription.GetType.ToString() & _
"<br><br><b>Target Site:</b><br>" & ErrorDescription.TargetSite.ToString() & _
"<br><br><b>Stack:</b><br>" & ErrorDescription.StackTrace & _
url = Request.Url.AbsoluteUri
Dim mailMessage As New MailMessage
mailMessage.From = "email@example.com"
mailMessage.To = "firstname.lastname@example.org"
mailMessage.Subject = "ATTENTION: Web Site Error"
mailMessage.BodyFormat = MailFormat.Html
mailMessage.Body = body
mailMessage.Body += url
System.Web.Mail.SmtpMail.SmtpServer = "SMTPServer"
While the user is logged in the site has the username as a session variable. How do I get the global.asax file to pass the username to me through this email?
I've added Session.Item("SSN").ToString and all that does is break and make it so it doesn't send an email at all. Any ideas? Thanks in advance for your assistance.