2011-07-17 55 views
0

我参加了一个简单的形式从网并把它放在一个网站,作为一个接触的形式使用,ALLS很好,它看起来还好,但是当我提交表单,我得到这个错误。 服务器对象错误ASP 0177:800401f3'ASP联系表格服务器对象错误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

您所在的服务器没有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 
+0

您好,谢谢,这是非常不同的,我的asp,我应该包含什么html在这里,以显示窗体?我的html不适合您的更改,感谢您的帮助 – Sarah

+0

@Sarah:这里没有涉及HTML;我已经重构了答案,以帮助您粘贴到代码中。你必须确保它适合你的应用程序。这意味着替换您的非工作的基于CDONTS的代码。 –

+0

为了完整的答案,值得一提的是CDONTS最后被包含在Windows 2000中,所以OP的主机在这里没有包含/支持它的问题。 –