Here's a function that I use to send myself emails incase there is an error. Take a look and see what's available for you to try:
Sub ErrMail(ByRef sbj As String, ByVal ex As String, Optional ByRef referrer As String = "unknown", Optional ByRef uname As String = "unknown", Optional ByRef ufn As String = "unknown", Optional ByRef uid As String = "unknown", Optional ByRef sPriority As String = "NORM")
Dim MyMail As MailMessage = New MailMessage()
Dim current As String = Request.ServerVariables("SCRIPT_NAME") & "?" & Request.ServerVariables("QUERYSTRING")
MyMail.From = "site@site.com"
MyMail.To = "email@email.com"
MyMail.Subject = sbj
MyMail.Body = sbj & vbCrLf & vbCrLf & "Reason:" & vbCrLf & ex & vbCrLf & vbCrLf & "Referring URL: " & referrer & vbCrLf & vbCrLf & "Current: " & current & vbCrLf & vbCrLf & "User: " & uname & " [" & ufn & " - " & uid & " | DateTime: " & DateTime.Now.ToString() & "]"
MyMail.BodyEncoding = Encoding.ASCII
MyMail.BodyFormat = MailFormat.Text
'You can also use HTML, but need to change the above line.
Select Case UCase(sPriority)
Case "HIGH" : MyMail.Priority = MailPriority.High
Case "LOW" : MyMail.Priority = MailPriority.Low
Case Else : MyMail.Priority = MailPriority.Normal
End Select
SmtpMail.SmtpServer = "mail.site.com" 'or SMTP server.
Try
SmtpMail.Send(MyMail)
Catch
End Try
End Sub
A lot of the parameters are optional, so keep that in mind.
A way to use this function:
Explained Example:
ErrMail("Subject of Email", "a quick message to yourself, or an Exception.ToString() method.", "referrer is referring url: Request.ServerVariables('HTTP_REFERRER')", "uname is users name if you are tracking a user", "ufn is the users full name, if you are tracking it", "uid is the users userid, if you are tracking it", "sPriority is for the priority of the mail: low, normal, high")
Live Example:
ErrMail("Database Exception Occurred At [" & Request.ServerVariables("SERVER_NAME") & "]", (strException).ToString())
This will spit out the code as:
ErrMail("Database Exception Occurred At [mydomainname]", "Exception information...")
Try sending one to yourself. It's a great way to fix bugs, and you know where they occurred, who was using the files at the time, and where they came from. Possibilities are endless.. you can even track down which string caused the error, and the full SQL of that string if it is a command.
Anyway, it's a guideline.