
15/04/2005, 10:28
|
 | | | Fecha de Ingreso: diciembre-2001 Ubicación: Guadalajara, Mexico
Mensajes: 3.672
Antigüedad: 23 años, 4 meses Puntos: 16 | |
Reportar errores por Email (Aporte) Hola, encontre esta funcion para mandar errores que se puedan producir via Correo usando AspMail por si a alguien le sirve, esto es como para tener mas control de nuestras paginas y poder darle seguimiento a errores que a veces no vemos hasta que nos los hacen ver
Código:
<%
'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 = "[email protected]" 'Email address of email sender
Const MAIL_TO_NAME = "MR. WEB DEVELOPER" 'Name of email recipient
Const MAIL_TO_EMAIL = "[email protected]" '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 = "<!DOCTYPE HTML PUBLIC""-//IETF//DTD HTML//EN"">"
HTML = HTML & "<html>"
HTML = HTML & "<head>"
HTML = HTML & "<title>" & MAIL_SUBJECT & "</title>"
HTML = HTML & "</head>"
HTML = HTML & "<body bgcolor=""FFFFFF"">"
HTML = HTML & "<p><font size =""3"" face=""Century Gothic, Arial"">"
HTML = HTML & "<b>" & MAIL_SUBJECT & "</b><br>"
HTML = HTML & "Error Report Generated: <FONT COLOR=""#3333FF"">" & FormatDateTime(now(), vbLongDate) & ", " & FormatDateTime(now(), vbLongTime) & "</font><br>"
HTML = HTML & "<hr>"
'Generate the error report general description
HTML = HTML & "<b>Details:</b><br>"
HTML = HTML & "Error In Page: <FONT COLOR=""#FF3333"">" & Request.ServerVariables("PATH_INFO") & "</FONT><BR>"
HTML = HTML & "Error Type: <FONT COLOR=""#FF3333"">" & ErrorType & "</FONT><BR>"
HTML = HTML & "Error Source: <FONT COLOR=""#FF3333"">" & ErrorSource & "</FONT><BR>"
HTML = HTML & "Error Number: <FONT COLOR=""#FF3333"">" & ErrorNumber & "</FONT><BR>"
HTML = HTML & "Error Description: <FONT COLOR=""#FF3333"">" & ErrorDescription & "</FONT><BR>"
HTML = HTML & "<hr>"
'Report the contents of the QueryString collection
HTML = HTML & "<b>QueryString Collection:</b><br>"
If QS.Count > 0 Then
For Each CollectionItem In QS
HTML = HTML & CollectionItem & " : <FONT COLOR=""#3333FF"">" & QS(CollectionItem) & "</FONT><br>"
Next
Else
HTML = HTML & "<FONT COLOR=""#FF3333"">The QueryString collection is empty</FONT><br>"
End If
HTML = HTML & "<hr>"
'Report the contents of the Form collection
HTML = HTML & "<b>Form Collection:</b><br>"
If RF.Count > 0 Then
For Each CollectionItem In RF
HTML = HTML & CollectionItem & " : <FONT COLOR=""#FF3333"">" & RF(CollectionItem) & "</FONT><br>"
Next
Else
HTML = HTML & "<FONT COLOR=""#3333FF"">The Form collection is empty</FONT><br>"
End If
HTML = HTML & "<hr>"
'Report the Server object properties
HTML = HTML & "<b>Server Settings:</b><br>"
HTML = HTML & "ScriptTimeout: <FONT COLOR=""#FF3333"">" & Server.ScriptTimeout & "</FONT><BR>"
HTML = HTML & "<hr>"
'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 & "<b>Session Settings:</b><br>"
HTML = HTML & "CodePage: <FONT COLOR=""#FF3333"">" & Session.CodePage & "</FONT><BR>"
HTML = HTML & "LCID: <FONT COLOR=""#FF3333"">" & Session.LCID & "</FONT><BR>"
HTML = HTML & "SessionID: <FONT COLOR=""#FF3333"">" & Session.SessionID & "</FONT><BR>"
HTML = HTML & "Timeout: <FONT COLOR=""#FF3333"">" & Session.TimeOut & "</FONT><BR>"
HTML = HTML & "<hr>"
HTML = HTML & "<b>Session Collection:</b><br>"
For iNumber = 1 To Session.Contents.Count
If IsObject(Session.Contents(iNumber)) Then
HTML = HTML & Session.Contents.Key(iNumber) & "<FONT COLOR=""#3333FF"">[Object]</FONT><BR>"
Else
If IsArray(Session.Contents(iNumber)) Then
HTML = HTML & Session.Contents.Key(iNumber) & "<FONT COLOR=""#3333FF"">[Array]</FONT><BR>"
Else
HTML = HTML & Session.Contents.Key(iNumber) & ": <FONT COLOR=""#3333FF"">" & Session.Contents(iNumber) & "</FONT><BR>"
End If
End If
Next
HTML = HTML & "<hr>"
'Report the contents of the Application collection
HTML = HTML & "<b>Application Collection:</b><br>"
For iNumber = 1 To Application.Contents.Count
If IsObject(Application.Contents(iNumber)) Then
HTML = HTML & Application.Contents.Key(iNumber) & "<FONT COLOR=""#3333FF"">[Object]</FONT><BR>"
Else
If IsArray(Application.Contents(iNumber)) Then
HTML = HTML & Application.contents.Key(iNumber) & "<FONT COLOR=""#3333FF"">[Array]</FONT><BR>"
Else
HTML = HTML & Application.contents.Key(iNumber) & ": <FONT COLOR=""#3333FF"">" & Application.Contents(iNumber) & "</FONT><BR>"
End If
End If
Next
HTML = HTML & "<hr>"
'Report the contents of the Server Variables collection
HTML = HTML & "<b>Server Variables:</b><br>"
For Each CollectionItem in request.servervariables
If CollectionItem <> "ALL_HTTP" and CollectionItem <> "ALL_RAW" then
HTML = HTML & CollectionItem & " : <FONT COLOR=""#3333FF"">" & request.servervariables(CollectionItem) & "</FONT><br>"
End If
Next
HTML = HTML & "</body>"
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
%>
__________________ CreandoWebs.com www.creandowebs.com PLANTILLAS TEMPLATEMONSTER CON 10% DE DESCUENTO |