0

我觉得我在这里遗漏了一些东西。我在 vbscript 中添加了一些不同的东西,试图让它只在单击提交按钮而不是两次时运行(第二次加载页面,然后提交),但它要么坏了它,要么没有用。对这个初学者程序员的任何帮助将不胜感激。如果您需要html,请告诉我。编辑:仍在寻求帮助!:(

<% Sub sendEmail(mailFrom, mailTo, mailSubject, mailMessage, mailServer, mailUsername, mailPassword)
Set MyMail = CreateObject("cdo.message")
MyMail.From = mailFrom
MyMail.To = mailTo
MyMail.Subject = mailSubject
MyMail.HTMLBody = mailMessage
MyMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
MyMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = mailServer
MyMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = mailUsername
MyMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = mailPassword
MyMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
MyMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
MyMail.Configuration.Fields.Update
MyMail.Send
Set MyMail = nothing
End Sub

Dim mailFrom, mailTo, mailSubject, mailMessage, mailServer, mailUsername, mailPassword

mailFrom = Request.form(example)
mailTo = "example"
mailSubject = "example"
mailMessage = "example"
mailServer = "example"
mailUsername = "example"
mailPassword = "example"

Call sendEmail(mailFrom, mailTo, mailSubject, mailMessage, mailServer, mailUsername, mailPassword)
%>
4

1 回答 1

1

如果Request.form(example) = ""然后页面不是表单提交的结果(或者表单是在没有此数据的情况下提交的),那么;

if Request.form(example) <> "" then
   'is a form submission
   .. email code
end if

如果您想更准确地区分提交,请在表单中添加一个常量隐藏字段

<input type="hidden" name="sendemail" value="1" />

并寻找Request.form("sendemail") = "1"

于 2012-09-11T12:40:10.643 回答