这可能与服务器有关。IIS6 和 IIS7 以不同的方式处理它。但是,这应该可以帮助您解决它。这是我从现有站点中提取并稍作改动的代码。您必须根据自己的目的进行扩充:
Response.Buffer = True
Dim strBody
Dim objCDOMail
Dim strMyEmailAddress
Dim strCCEmailAddress
Dim strBCCEmailAddress
Dim strReturnEmailAddress
'THIS IS WHERE YOU CHANGE THE EMAIL ADDRESS
strMyEmailAddress = "you@yourdomain.com"
'strBCCEmailAddress = "bcc@yourdomain.com"
strReturnEmailAddress = Request.Form("Email")
strBody = strBody & "<br /><br /><span><strong>Name:</strong></span> " & Request.Form("name")
strBody = strBody & "<br /><br /><span><strong>E-mail:</strong></span> " & Request.Form("email")
strBody = strBody & "<br /><br /><span><strong>Company:</strong></span> " & Request.Form("company")
strBody = strBody & "<br /><br /><span><strong>Enquiry:</strong></span> " & Request.Form("enquiry")
strBody = strBody & "</p></div></body>"
If Len(strReturnEmailAddress) < 5 OR NOT Instr(1, strReturnEmailAddress, " ") = 0 OR InStr(1, strReturnEmailAddress, "@", 1) < 2 OR InStrRev(strReturnEmailAddress, ".") < InStr(1,strReturnEmailAddress, "@", 1) Then
strReturnEmailAddress = strMyEmailAddress
End If
Set objCDOMail = Server.CreateObject("CDO.Message")
objCDOMail.From = Request.Form("name") & " <" & strReturnEmailAddress & ">"
objCDOMail.To = strMyEmailAddress
objCDOMail.Cc = strCCEmailAddress
objCDOMail.Bcc = strBCCEmailAddress
objCDOMail.Subject = "Your Email Subject"
objCDOMail.HTMLBody = strBody '**This is for HTML Emails**
objCDOMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing")=2
objCDOMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver")="localhost"
objCDOMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport")=25
objCDOMail.Configuration.Fields.Update
objCDOMail.Send
Set objCDOMail = Nothing
最后几行处理服务器并使用本地主机发送邮件。您可以根据您的 SMTP 服务器更改此设置。