ASP联系表单服务器对象错误'ASP 0177:800401f3'

时间:2011-07-17 14:38:38

标签: forms asp-classic

我从网上拿了一个简单的表格并把它放在一个网站上用作联系表格,一切都很好,看起来没问题,但是当我提交表单时,我收到了这个错误。 服务器对象错误'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
%>

提前致谢

1 个答案:

答案 0 :(得分: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