我有一个小问题,因为我不知道asp。但为我的Uncles网站创建的页面是在asp中,表格也是如此。我无法让他的表单工作并搜索错误,并从fasthost发现了一个pdf,我正在尝试这个代码但不明白我把电子邮件地址发送到哪里以及如何添加其他信息,如名称。
这是我正在尝试的代码:
dim oCdoMsg, oCdoConfg, strReferer, strServer,
strClientIP, strServerIP, blnSpam
set oCdoMsg = server.createobject("CDO.Message")
strReferer = request.servervariables("HTTP_REFERER")
strServer = Replace(request.servervariables("SERVER_NAME"), "www.", "")
strClientIP = request.servervariables("REMOTE_ADDR")
strServerIP = request.servervariables("LOCAL_ADDR")
strFrom = "noreply@" & strServer
intComp = inStr(strReferer, strServer)
If intComp > 0 Then
blnSpam = False
Else
' Spam Attempt Block
blnSpam = True
End If
oCdoMsg.to = request.form("email")
oCdoMsg.from = strFrom
oCdoMsg.Subject = "CDO Test Mail"
oCdoMsg.Textbody = "This test mail has been sent from
server "
oCdoMsg.Textbody = oCdoMsg.Textbody &
request.servervariables("LOCAL_ADDR") & " via CDO mail
objects."
strMSSchema =
"http://schemas.microsoft.com/cdo/configuration/"
Set oCdoConfg = Server.CreateObject("CDO.Configuration")
oCdoConfg.Fields.Item(strMSSchema & "sendusing") = 2
oCdoConfg.Fields.Item(strMSSchema & "smtpserver") =
"smtp.fasthosts.co.uk"
oCdoConfg.Fields.Update
Set oCdoMsg.Configuration = oCdoConfg
If NOT blnSpam Then
oCdoMsg.send
strResult = "Mail Sent."
Else
strResult = "Mail Not Sent."
End If
response.write strResult
set oCdoMsg = nothing
set oCdoConfg = nothing
我将不胜感激任何帮助,现在网站上的代码显示500错误。这就是为什么我需要使用上面的代码。我只需要帮助我在哪里添加我的域名电子邮件,以及如何将表单的其他部分(如名称)引入上面的代码中。
由于
答案 0 :(得分:0)
首先,您需要启用详细错误http://goo.gl/Ao3Ss。 然后你会看到错误是什么 似乎你应该调查VBScript's multiline syntax。因为,有些行会导致代码中出现语法错误。 几个例子:
<强>错误:强>
dim oCdoMsg, oCdoConfg, strReferer, strServer,
strClientIP, strServerIP, blnSpam
strMSSchema =
"http://schemas.microsoft.com/cdo/configuration/"
oCdoMsg.Textbody = "This test mail has been sent from
server "
<强>正确:强>
dim oCdoMsg, oCdoConfg, strReferer, strServer, _
strClientIP, strServerIP, blnSpam
strMSSchema = _
"http://schemas.microsoft.com/cdo/configuration/"
oCdoMsg.Textbody = "This test mail has been sent from server "
考虑所有这些。