通过表单发送数据时出错(Office365)

时间:2013-08-06 14:33:50

标签: asp-classic

我正在尝试从表单发送此信息时调试此问题,但我一直收到此错误。

error '8004020e'
/contacthandler.asp, line 45

我在asp中没有做太多工作,但是我已经设法从以前的开发人员那里稍微清理了这个文件(仍然有错误)。错误发生在.Send ..忘了澄清这一点。

这是代码。任何帮助表示赞赏。

'declare variables
dim name, phone, email, comment, service, returnPage

'set variables to the corresponding fields from contact form
name = request.form("custName")
phone = request.form("custPhone")
email = request.form("custEmail")
comment = request.form("custNotes")
service = request.form("service")
returnPage = request.form("page")

dim theEmail
' set the email content data
theEmail = "<h3>Contact from website, information below.</h3><table border='0'><tr><th>Customer Name:<td>"&name
theEmail = theEmail&"<tr><th>Phone Number:<td>"&phone&"<tr><th>Email Address:<td>"&email&"<tr><th>Service Category:<td>"&service
theEmail = theEmail&"<tr><th valign='top'>Comments/Notes:<td>"&comment&"</table>"

' send the email

dim sch
sch = "http://schemas.microsoft.com/cdo/configuration/" 

Set cdoConfig = CreateObject("CDO.Configuration") 


With cdoConfig.Fields 
    .Item(sch & "sendusing") = 2 ' cdoSendUsingPort 
    .Item(sch & "smtpserverport") = 587
    .Item(sch & "smtpserver") = "smtp.office365.com"
    .Item(sch & "smtpauthenticate") = 1
    .Item(sch & "sendusername") = "########"
    .Item(sch & "sendpassword") = "########"
    .update 
End With 

Set cdoMessage = CreateObject("CDO.Message") 

With cdoMessage 
    Set .Configuration = cdoConfig 
    .From = name & "<" & email & ">" 
    .To = "info@mywebsite.com" 
    .Subject = "Website - "&service&" Request" 
    .HTMLBody = theEmail
    .Send 
End With 

Set cdoMessage = Nothing 
Set cdoConfig = Nothing 


'response.write "sent, check the mail"
response.redirect "thankyou.asp"
'returnPage&".asp"

2 个答案:

答案 0 :(得分:0)

MSDN(http://msdn.microsoft.com/en-us/library/ms527318%28v=exchg.10%29.aspx)建议您需要格式化.From字段,如下所示:

.From """" & name & """ <" & email & ">"

答案 1 :(得分:0)

我使用谷歌查找错误代码,我发现很多网站他们认为发送数据存在问题。这可能是另一个麻烦的来源。

如果您更换

会发生什么
.Item(sch & "sendusing") = 2 ' cdoSendUsingPort

通过

.Item(cdoSendUsingMethod) = 1 'cdoSendUsingPickup

额外试一试,没有任何评论。