-1
我有一個網站是除「聯繫」頁面以外的所有靜態內容。我的託管服務讓我在IIS服務器上,所以他們給了我通用的cdosys.asp文件。正如你知道的,如果你使用過cdosys.asp,你可以通過聯繫頁面提交表單提交表單,然後cdosys.asp將任何網站訪問者通過電子郵件發送給我的表單域,然後轉發訪問者到「感謝寫作」頁面。如何在「經典ASP」中編輯cdosys.asp來發送電子郵件?
這是我的小故障。我學到的唯一服務器端語言是ColdFusion。沒有ASP。 cdosys文件非常簡單,足以證明我改變了一些文本字符串,因此它指向我的郵件服務器,然後指向感謝頁面。但是,我的聯繫人輸入表格只需要三個提供的字段中的一個。兩個是可選的。但是cdosys對此感到窒息。它認爲所有的領域都是必需的。它只有在所有三個都有內容時纔有效。我搜索了所有試圖找到一箇舊的ASP教程。可以請一些親切的ASP在那裏告訴我如何編輯下面的代碼,以允許我的三個表單字段中的兩個沒有內容,並仍然給我發電子郵件?
<%
For Field = 1 to Request.Form.Count - 3
FieldName = Replace(Request.Form.Key(Field),"_"," ")
FieldValue = Request.Form.Item(Field)
Body = Body & FieldName & ": " & FieldValue & VbCrLf
Next
'Dimension variables
Dim objCDOSYSCon
'Create the e-mail server object
Set objCDOSYSMail = Server.CreateObject("CDO.Message")
Set objCDOSYSCon = Server.CreateObject ("CDO.Configuration")
'Set and update fields properties
With objCDOSYSCon
'Outgoing SMTP server
.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mail.domain.com" 'was "SMTPSERVER"
.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 'CDO Port
.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 'Timeout
.Fields("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
.Fields.Update
End With
'Update the CDOSYS Configuration
Set objCDOSYSMail.Configuration = objCDOSYSCon
'Set and update email properties
With objCDOSYSMail
'0=Low, 1=Normal, 2=High
.Fields("urn:schemas:httpmail:importance").Value = 1
'Who the e-mail is from
.From = Request.Form("email_address")
'Who the e-mail is sent to
.To = "[email protected]"
'Who the e-mail is CC'd to
.Cc = ""
'The subject of the e-mail
.Subject = Request.Form("email_subject")
'Set the e-mail body format (HTMLBody=HTML TextBody=Plain)
.TextBody = Body
.Fields.Update
'Send the e-mail
.Send
End With
'Close the server mail object
Set objCDOSYSMail = Nothing
Set objCDOSYSCon = Nothing
'Rederect after sending email
Response.Redirect Request.Form("redirect_to")
%>
得到這個錯誤(第49行是哪裏。發送所在): – user722951 2011-04-25 03:07:24
哎呀,並顯示錯誤消息再次... CDO.Message.1錯誤「 8004020d' 至少需要一個「發件人」或「發件人」字段,且均未找到。 /kthings/cdosys.asp,第49行 – user722951 2011-04-25 03:08:23
確保您將實際值發送到.From和.Sender字段。在我看來,像傳入的表單沒有用於填寫.From的email_address。 – 2011-04-29 18:50:54