精彩专题推荐:建站之入门课 建站之必修课 建站之关键课 网站价值所在 流量提高专题 css+div 标准 个人网站打造全过程
  • 让你的网站产生收益赚钱,有博客和网站的绝对不能错过
  • 将指定的流量带到你的网站,为你站增加有效的访客,为你提升业绩
  • 网页不存在自动给管理员发邮件的ASP代码

    来源:网页教学网 时间:07-11-03 点击: 点击这里收藏本文

      制作网站的时候通常会有当访客的一些错误操作或我们网站本身的缺陷,造成某个不存在的页面被访问,这时会出现404错误提示信息,如果是热心的访客可能会给你发一封邮件提示你,当时大部分时候是访客不会给我们发邮件的。用ASP做一个实用的程序,当用户访问出现404错误提示信息的时候系统会自动发一封邮件给我们,这样就不必担心了,制作代码如下:

    <% @language="vbscript" %>
    <% Option Explicit %>
    <%
    Dim strPage, strReferer, strMessage
    Dim objSMTP
    ' Log the offending page
    strPage = Request.ServerVariables("HTTP_URL")
    ' Log the referer
    strReferer = Request.ServerVariables("HTTP_REFERER")
    ' Set up the email component
    Set objSMTP = Server.CreateObject("JMail.Message")
    objSMTP.From = "you@yourdomain.com"
    objSMTP.FromName = "Your Domain"
    objSMTP.Subject = "404 Error Logged"
    objSMTP.AddRecipient("you@yourdomain.com")
    ' Write the message
    strMessage = "Requested page: " & strPage & vbCrLf & vbCrLf
    If strReferer <> "" Then
    strMessage = strMessage & "Referer: " & strReferer
    Else
    strMessage = strMessage "The visitor typed the address in"
    End If
    objSMTP.Body = strMessage
    ' Send the message
    objSMTP.Send("mail.jzxue.com")
    ' Tidy up
    objSMTP.ClearRecipients
    objSMTP.Close()
    Set objSMTP = Nothing
    %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
    "http://www.w3.org/TR/html4/strict.dtd">
    <html lang="en">
    <head>
    <title>404 Page Not Found</title>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    </head>
    <body>
    <h1>404 Page Not Found Error</h1>
    <p>
    Appropriate message here.
    </p>
    </body>
    </html>


    用户评论

    广而告之