<% 'Function to send an alert email 'Script from http://www.aspalliance.com/brettb/ErrorReportEmailer.asp 'Parameters used are: ' ErrorType = The type of error (e.g. "ASP Error") ' ErrorSource= Error source ' ErrorNumber = Error number ' ErrorDescription= Error description ' 'Changes required if you wish to use this script: ' '1. Change the constant declarations so the email goes to you! ' '2. If you disable session state then you must comment out the ' part of the script that extracts the details of the Session object ' '3. If you want to use a mail sending object other than ASPMail you need to ' alter the mail sending part of the script Function SendErrorEmail(ErrorType, ErrorSource, ErrorNumber, ErrorDescription)    On Error Resume Next    'Declare variables     Dim HTML 'The HTML to send in the email     Dim CollectionItem     Dim iNumber     Dim myMail 'Mail Server Component     Dim QS     Dim RF     'Transfer the contents of the QueryString and Form collections to variables     Set QS = Request.QueryString     Set RF = Request.Form     'Declare constants. YOU MUST CHANGE THESE WHEN USING THE SCRIPT ON YOUR OWN SITE     Const MAIL_FROM_NAME = "MY WEBSERVER ERROR HANDLER" 'Name of email sender     Const MAIL_FROM_EMAIL = "someone@someserver.com" 'Email address of email sender     Const MAIL_TO_NAME = "MR. WEB DEVELOPER" 'Name of email recipient     Const MAIL_TO_EMAIL = "someoneelse@someotherserver.com" 'Email address of email recipient     Const MAIL_SUBJECT = "My Webserver Error Report" 'Title of error report     Const MAIL_HOST = "smtp.someisp.com" 'Address of the host used to send the mail     'Generate the top part of the error report     HTML = ""     HTML = HTML & ""     HTML = HTML & ""     HTML = HTML & "" & MAIL_SUBJECT & ""     HTML = HTML & ""     HTML = HTML & ""     HTML = HTML & "

"     HTML = HTML & "" & MAIL_SUBJECT & "
"     HTML = HTML & "Error Report Generated: " & FormatDateTime(now(), vbLongDate) & ", " & FormatDateTime(now(), vbLongTime) & "
"     HTML = HTML & "


"     'Generate the error report general description     HTML = HTML & "Details:
"     HTML = HTML & "Error In Page: " & Request.ServerVariables("PATH_INFO") & "
"     HTML = HTML & "Error Type: " & ErrorType & "
"     HTML = HTML & "Error Source: " & ErrorSource & "
"     HTML = HTML & "Error Number: " & ErrorNumber & "
"     HTML = HTML & "Error Description: " & ErrorDescription & "
"     HTML = HTML & "
"     'Report the contents of the QueryString collection     HTML = HTML & "QueryString Collection:
"     If QS.Count > 0 Then     For Each CollectionItem In QS             HTML = HTML & CollectionItem & " : " & QS(CollectionItem) & "
"     Next     Else     HTML = HTML & "The QueryString collection is empty
"     End If     HTML = HTML & "
"    'Report the contents of the Form collection     HTML = HTML & "Form Collection:
"     If RF.Count > 0 Then     For Each CollectionItem In RF             HTML = HTML & CollectionItem & " : " & RF(CollectionItem) & "
"     Next     Else     HTML = HTML & "The Form collection is empty
"     End If     HTML = HTML & "
"    'Report the Server object properties     HTML = HTML & "Server Settings:
"     HTML = HTML & "ScriptTimeout: " & Server.ScriptTimeout & "
"     HTML = HTML & "
"     'Report the Session object properties and the contents of the Session collection     'IMPORTANT: If you have disabled Sessions either in IIS or     'by use of the @ENABLESESSIONSTATE = FALSE directive then you MUST comment out this section     HTML = HTML & "Session Settings:
"     HTML = HTML & "CodePage: " & Session.CodePage & "
"     HTML = HTML & "LCID: " & Session.LCID & "
"     HTML = HTML & "SessionID: " & Session.SessionID & "
"     HTML = HTML & "Timeout: " & Session.TimeOut & "
"     HTML = HTML & "
"     HTML = HTML & "Session Collection:
"     For iNumber = 1 To Session.Contents.Count         If IsObject(Session.Contents(iNumber)) Then             HTML = HTML & Session.Contents.Key(iNumber) & "[Object]
"         Else             If IsArray(Session.Contents(iNumber)) Then                 HTML = HTML & Session.Contents.Key(iNumber) & "[Array]
"             Else                 HTML = HTML & Session.Contents.Key(iNumber) & ": " & Session.Contents(iNumber) & "
"             End If         End If     Next     HTML = HTML & "
"    'Report the contents of the Application collection     HTML = HTML & "Application Collection:
"     For iNumber = 1 To Application.Contents.Count         If IsObject(Application.Contents(iNumber)) Then             HTML = HTML & Application.Contents.Key(iNumber) & "[Object]
"         Else             If IsArray(Application.Contents(iNumber)) Then                 HTML = HTML & Application.contents.Key(iNumber) & "[Array]
"             Else                 HTML = HTML & Application.contents.Key(iNumber) & ": " & Application.Contents(iNumber) & "
"             End If         End If     Next     HTML = HTML & "
"    'Report the contents of the Server Variables collection     HTML = HTML & "Server Variables:
"     For Each CollectionItem in request.servervariables         If CollectionItem <> "ALL_HTTP" and CollectionItem <> "ALL_RAW" then             HTML = HTML & CollectionItem & " : " & request.servervariables(CollectionItem) & "
"         End If     Next     HTML = HTML & ""     HTML = HTML & ""     'Send the error report using email. This currently uses ASPMail from serverobjects.com, but could be     'adapted to use another mail sending object (e.g. CDONTS) if required     Set myMail = Server.CreateObject("SMTPsvg.Mailer")     myMail.RemoteHost = MAIL_HOST     myMail.FromName = MAIL_FROM_NAME     myMail.FromAddress = MAIL_FROM_EMAIL     myMail.AddRecipient MAIL_TO_NAME, MAIL_TO_EMAIL     myMail.Subject = MAIL_SUBJECT     myMail.BodyText = HTML     myMail.ContentType = "text/html"     If Not myMail.SendMail then         SendErrorEmail = 0     Else         SendErrorEmail = 1     End If     Set myMail = Nothing End Function %>