asp 表单邮件自动回复
asp formmail auto responder
我编码很烂
我有一个 asp 用于订阅电子邮件的表单邮件。我确实收到电子邮件,但我想发送自动回复 "Thank you for subscription"。我的联系页面 formmail 也一样。
下面是我当前的代码
你能告诉我该怎么做吗?
<%
dim sEmailContent
sEmailContent = sEmailContent & "Subscribe : " & Request.Form("subscribe") & vbCrLf
Response.Write(sEmailContent)
'call send_email("here@herringboneandsui.com",sEmailContent)
call send_email("here@herringboneandsui.com",sEmailContent)
function send_email(sToEmail,sEmailBody)
on error resume next
Dim ObjSendMail
Set ObjSendMail = CreateObject("CDO.Message")
'Configuration for remote SMTP server
'Network Send
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
'Name of SMTP server
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") ="relay-hosting.secureserver.net"
'SMTP port
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
'MaxESP SMTP servers require authentication
'Basic Authentication
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
'SMTP username as configured in the control panel
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") ="bla@bla.com"
'SMTP user password as configured in the control panel
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") ="blabla"
ObjSendMail.Configuration.Fields.Update
'Configuration for email message
'Email To address
'ObjSendMail.To = "bla@gmail.com"
'ObjSendMail.To = "bla@mac.com"
ObjSendMail.To = sToEmail
'Email Subject
ObjSendMail.Subject = "Newsletter Subscription"
'Email From address
ObjSendMail.From = "bla@herringboneandsui.com"
'Email Body
ObjSendMail.TextBody = sEmailBody
ObjSendMail.Send
Set ObjSendMail = Nothing
response.Redirect("thank-you.html")
if err.number <> 0 then
Response.Write(err.Description)
end if
on error goto 0
end function
%>
将函数 function send_email(sToEmail,sEmailBody)
移动到单独的文件中,假设移动到 "Emails.asp"。
在联系页面和订阅 asp 页面中添加以下行以包含您的 "Email.asp"
<!-- #include file="Emails.asp" -->
然后像以前一样调用send_email
我编码很烂
我有一个 asp 用于订阅电子邮件的表单邮件。我确实收到电子邮件,但我想发送自动回复 "Thank you for subscription"。我的联系页面 formmail 也一样。
下面是我当前的代码 你能告诉我该怎么做吗?
<%
dim sEmailContent
sEmailContent = sEmailContent & "Subscribe : " & Request.Form("subscribe") & vbCrLf
Response.Write(sEmailContent)
'call send_email("here@herringboneandsui.com",sEmailContent)
call send_email("here@herringboneandsui.com",sEmailContent)
function send_email(sToEmail,sEmailBody)
on error resume next
Dim ObjSendMail
Set ObjSendMail = CreateObject("CDO.Message")
'Configuration for remote SMTP server
'Network Send
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
'Name of SMTP server
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") ="relay-hosting.secureserver.net"
'SMTP port
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
'MaxESP SMTP servers require authentication
'Basic Authentication
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
'SMTP username as configured in the control panel
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") ="bla@bla.com"
'SMTP user password as configured in the control panel
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") ="blabla"
ObjSendMail.Configuration.Fields.Update
'Configuration for email message
'Email To address
'ObjSendMail.To = "bla@gmail.com"
'ObjSendMail.To = "bla@mac.com"
ObjSendMail.To = sToEmail
'Email Subject
ObjSendMail.Subject = "Newsletter Subscription"
'Email From address
ObjSendMail.From = "bla@herringboneandsui.com"
'Email Body
ObjSendMail.TextBody = sEmailBody
ObjSendMail.Send
Set ObjSendMail = Nothing
response.Redirect("thank-you.html")
if err.number <> 0 then
Response.Write(err.Description)
end if
on error goto 0
end function
%>
将函数 function send_email(sToEmail,sEmailBody)
移动到单独的文件中,假设移动到 "Emails.asp"。
在联系页面和订阅 asp 页面中添加以下行以包含您的 "Email.asp"
<!-- #include file="Emails.asp" -->
然后像以前一样调用send_email