【问题标题】:ASP Contact form Server object error 'ASP 0177 : 800401f3'ASP 联系表单服务器对象错误“ASP 0177:800401f3”
【发布时间】:2011-07-17 14:38:37
【问题描述】:

我从网上拿了一个简单的表格并将其放在网站上用作联系表格,一切都很好,看起来还可以,但是当我提交表格时,我收到了这个错误。 服务器对象错误“ASP 0177:800401f3”

Server.CreateObject 失败

/new/contactusprocess.asp,第 31 行

800401f3


这是代码

<%
Dim error
error = 0
For Each f In Request.Form
  If Request.Form(f) = "" Then 
    error = 1
  End If
Next
If error=1 Then
  response.redirect "error.html"
Else
Dim f, emsg, mail_to, r, o, c, other
fline = "_______________________________________________________________________"& vbNewLine   
hline = vbNewLine & "_____________________________________"& vbNewLine   
emsg = ""

For Each f In Request.Form
   If mid(f,1,1)<>"S"  = True Then 'do not save if input name starts with S
     emsg  = emsg & f & " = " &  Trim(Request.Form(f)) & hline
   End If
Next

Set objNewMail = Server.CreateObject("CDONTS.NewMail")
    objNewMail.From = Request("Email Address")
    objNewMail.Subject = "Message from contact page (version: 1.0)"
    objNewMail.To = mail_to
    objNewMail.Body = emsg & fline
    objNewMail.Send
    Set objNewMail = Nothing

response.redirect "thankyou.html"
End if
%>

提前致谢

【问题讨论】:

    标签: forms asp-classic


    【解决方案1】:

    您所在的服务器没有CDONTS 库。建议改用CDO.Message。 与您的主机确认他们支持从经典 ASP 发送电子邮件。

    用此代码替换您的代码(从包含 CDONTS 的行到 + 包括 Response.Redirect)。

       Dim  to, from, subj, body
       from = Request("Email Address")
       subj = "Message from contact page (version: 1.0)"
    
       SendMail(subj, from, mail_to, emsg & fline)
       Response.Redirect "thankyou.html"
    End If
    
    '******* a method to encapsulate our emailing functionality
    Sub SendMail(subject, from, to, body)
        Dim sConfURL, cdoConfig, cdoMessage 
    
        Set cdoConfig = CreateObject("CDO.Configuration") 
        sConfURL = "http://schemas.microsoft.com/cdo/configuration/"
        With cdoConfig.Fields 
            .Item(sConfURL & "sendusing") = 2
            ,Item(sConfURL & "smtpserver") = "localhost"
            .Item(sConfURL & "smtpserverport") = 25
            .Update 
        End With
    
        Set cdoMessage = CreateObject("CDO.Message") 
    
        With cdoMessage
            Set .Configuration = cdoConfig 'may have to remove the Set if an error here.
            .From = from
            .To = to
            .Subject = subject
            .TextBody = body
            .Send
        End With
    
        Set cdoMessage = Nothing 
        Set cdoConfig = Nothing 
    End Sub
    

    【讨论】:

    • 您好,谢谢,这与我的 asp 非常不同,我应该在此处包含什么 html 以显示表单?我的 html 不适应您的更改,感谢您的帮助
    • @Sarah:这里不涉及 HTML;我已经重构了答案以帮助您粘贴到您的代码中。您必须确保它适合您的应用程序。这是为了替换您的非工作基于 CDONTS 的代码。
    • 为了回答的完整性,值得一提的是,CDONTS 最后一次包含在 Windows 2000 中,因此 OP 的主机在这里没有包含/支持它的错误。
    • 我仍然收到此错误 Microsoft VBScript 编译错误 '800a03f2' Expected identifier /new/contactusprocess.asp, line 10 Dim to, from, subj, body -----^
    • @Sarah:第 10 行到底是什么?
    猜你喜欢
    • 1970-01-01
    • 2012-10-08
    • 2015-10-01
    • 2013-10-23
    • 1970-01-01
    • 2018-09-19
    • 2019-12-07
    • 2010-12-03
    • 1970-01-01
    相关资源
    最近更新 更多