CDO.Message在页面加载时发送,但表单不提交 [英] CDO.Message sent whenever page loads, though the form not submitte
问题描述
如果填写并提交表单,下面的脚本可以正常工作。
但是只要页面加载就会发送(空白)电子邮件,即使表单是
未提交。我希望仅在表格提交时才收到电子邮件
提交
<%@ LANGUAGE =" VBSCRIPT"%>
<%
设置MyMail = CreateObject(" CDO.Message")
MyMail.TextBody = Request.Form(" name")& vbCrLf& _
Request.Form(" email")& vbCrLf& _
Request.Form(" phone")& vbCrLf& _
Request.Form(" palaver")
MyMail.From =" ra*****@yahoo.com "
MyMail.To =" ar **@gmail.com"
MyMail.Cc =""
MyMail.Bcc =""
MyMail.Subject =" cosas de cuero"
MyMail.Send()
设置MyMail = Nothing
%>
>
第二部分:下面的脚本可能是问题的一部分。它是在关闭表单标签下面的html
主体< / formand在提交表单时工作,
但是我不想使用它,而是使用它有一个重定向到
确认页面。
但如果我使用response.redirect,则表单的页面永远不会打开。只有
确认页面打开。
所以我有两个问题,显然是新手。
这个论坛过去一直都是救星
谢谢
Alan Lipman
alegra ***** @ yahoo.com
ca ********** @ hotmail.com
<%
dim email
email = Request.Form(" email")
如果是电子邮件<>""然后
Response.Write(" Hello"& email&"!< br />")
Response.Write(" We已经收到你的提交)
结束如果
%>
The script below works fine if the form is filled out and submitted.
But a (blank) e-mail is sent whenever the page loads, even when the form is
not submitted. I would like to receive the e-mail only when the form is
submitted
<%@LANGUAGE="VBSCRIPT"%>
<%
Set MyMail=CreateObject("CDO.Message")
MyMail.TextBody=Request.Form("name") & vbCrLf & _
Request.Form("email")& vbCrLf & _
Request.Form("phone")& vbCrLf & _
Request.Form("palaver")
MyMail.From=" ra*****@yahoo.com"
MyMail.To="ar**@gmail.com"
MyMail.Cc=""
MyMail.Bcc=""
MyMail.Subject="cosas de cuero"
MyMail.Send()
Set MyMail=Nothing
%>
Part two: The script below could be part of the problem. It is in the html
body below the closing form tag </formand works when the form is submitted,
but I would prefer not to use it, but instead to have a redirect to a
confirmation page.
But if I use "response.redirect", the page with the form never opens. Only
the confirmation page opens.
So I have two questions, and am obviously a novice.
This forum has been a lifesaver in the past
Thanks
Alan Lipman
alegra*****@yahoo.com
ca**********@hotmail.com
<%
dim email
email=Request.Form("email")
If email<>"" Then
Response.Write("Hello " & email & "!<br />")
Response.Write("We have receved your submission")
End If
%>
推荐答案
有有多种方法可以检查表单是否已发布。一个
是Request.ServerVariables(" REQUEST_METHOD")
如果Request.ServerVariables(" REQUEST_METHOD")=" POST"然后
'''''你的电子邮件代码
结束如果
至于第2部分,将Response.Redirect放入在发送电子邮件的
代码之后,IF阻止。
<%
如果Request.ServerVariables (REQUEST_METHOD)=" POST"然后
''''电子邮件代码
Response.Redirect" confirmed.asp"
结束如果
%>
< form .....
Ray at work
" whyyyy" < wh **** @ discussion.microsoft.com写信息
新闻:C6 ************************ ********** @ microsof t.com ...
There are a number of ways to check to see if the form has been posted. One
is Request.ServerVariables("REQUEST_METHOD")
If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
''''''your code for e-mailing
End If
As for part 2, put the Response.Redirect in that IF block as well after the
code that sends the e-mail.
<%
If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
''''code for e-mail
Response.Redirect "confirmed.asp"
End If
%>
<form.....
Ray at work
"whyyyy" <wh****@discussions.microsoft.comwrote in message
news:C6**********************************@microsof t.com...
如果填写并提交表单,下面的脚本可以正常工作。 />
但是每当页面加载时都会发送一个(空白)电子邮件,即使表格
未提交
也是如此。我希望只在表格提交时收到电子邮件
提交
The script below works fine if the form is filled out and submitted.
But a (blank) e-mail is sent whenever the page loads, even when the form
is
not submitted. I would like to receive the e-mail only when the form is
submitted
第二部分:下面的脚本可以成为问题的一部分。它是在结束表格标签< / formand下方的html
正文中,当表格是
提交时,
但我更喜欢不要使用它,而是重定向到
确认页面。
但是如果我使用response.redirect,则页面包含形式永远不会打开。只有
确认页面打开。
所以我有两个问题,显然是新手。
这个论坛在过去一直是救星
谢谢
Alan Lipman
al ********* @ yahoo.com
ca ********** @ hotmail.com
<%
dim email
email = Request.Form(" email")
如果是电子邮件<>""然后
Response.Write(" Hello"& email&"!< br />")
Response.Write(" We已经收到你的提交)
结束如果
%>
Part two: The script below could be part of the problem. It is in the html
body below the closing form tag </formand works when the form is
submitted,
but I would prefer not to use it, but instead to have a redirect to a
confirmation page.
But if I use "response.redirect", the page with the form never opens. Only
the confirmation page opens.
So I have two questions, and am obviously a novice.
This forum has been a lifesaver in the past
Thanks
Alan Lipman
al*********@yahoo.com
ca**********@hotmail.com
<%
dim email
email=Request.Form("email")
If email<>"" Then
Response.Write("Hello " & email & "!<br />")
Response.Write("We have receved your submission")
End If
%>
Hello Ray
谢谢
我不确定你是否解决了第一个问题,即每次打开页面时如何防止发送一封
银行电子邮件,无论是否
表格已提交。
感谢您对response.redirect的帮助,第二个问题
此致
艾伦
" Ray Costanzo [MVP]"写道:
Hello Ray
Thanks
I''m not sure if you anserwed the first question, which is how to prevent a
bank e-mail from being sent every time the page is opened, whether or not the
form is submitted.
Thanks for the help with response.redirect, the second question
Sincerely
Alan
"Ray Costanzo [MVP]" wrote:
有很多方法可以检查表格是否已发布。一个
是Request.ServerVariables(" REQUEST_METHOD")
如果Request.ServerVariables(" REQUEST_METHOD")=" POST"然后
'''''您的电子邮件代码
结束如果
至于第2部分,请将在发送电子邮件的
代码之后的那个IF块中的Response.Redirect。
<%
如果Request.ServerVariables(" REQUEST_METHOD")=" POST"然后
''''电子邮件代码
Response.Redirect" confirmed.asp"
结束如果
%>
< form .....
Ray at work
whyyyy < wh **** @ discussion.microsoft.com写信息
新闻:C6 ************************ ********** @ microsof t.com ...
There are a number of ways to check to see if the form has been posted. One
is Request.ServerVariables("REQUEST_METHOD")
If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
''''''your code for e-mailing
End If
As for part 2, put the Response.Redirect in that IF block as well after the
code that sends the e-mail.
<%
If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
''''code for e-mail
Response.Redirect "confirmed.asp"
End If
%>
<form.....
Ray at work
"whyyyy" <wh****@discussions.microsoft.comwrote in message
news:C6**********************************@microsof t.com...
如果填写并提交表单,下面的脚本可以正常工作。 />
但是每当页面加载时都会发送一个(空白)电子邮件,即使表格
未提交
也是如此。我想收到电子邮件时才提供表格
提交
The script below works fine if the form is filled out and submitted.
But a (blank) e-mail is sent whenever the page loads, even when the form
is
not submitted. I would like to receive the e-mail only when the form is
submitted
第二部分:下面的脚本可能是问题的一部分。它是在结束表格标签< / formand下方的html
正文中,当表格是
提交时,
但我更喜欢不要使用它,而是重定向到
确认页面。
但是如果我使用response.redirect,则页面包含形式永远不会打开。只有
确认页面打开。
所以我有两个问题,显然是新手。
这个论坛在过去一直是救星
谢谢
Alan Lipman
al ********* @ yahoo.com
ca ********** @ hotmail.com
<%
dim email
email = Request.Form(" email")
如果是电子邮件<>""然后
Response.Write(" Hello"& email&"!< br />")
Response.Write(" We已经收到你的提交)
结束如果
%>
Part two: The script below could be part of the problem. It is in the html
body below the closing form tag </formand works when the form is
submitted,
but I would prefer not to use it, but instead to have a redirect to a
confirmation page.
But if I use "response.redirect", the page with the form never opens. Only
the confirmation page opens.
So I have two questions, and am obviously a novice.
This forum has been a lifesaver in the past
Thanks
Alan Lipman
al*********@yahoo.com
ca**********@hotmail.com
<%
dim email
email=Request.Form("email")
If email<>"" Then
Response.Write("Hello " & email & "!<br />")
Response.Write("We have receved your submission")
End If
%>
我不确定你是否解决了第一个问题,即如何防止
I''m not sure if you anserwed the first question, which is how to prevent a
每次打开网页时发送的银行电子邮件,无论是否
表格已提交。
bank e-mail from being sent every time the page is opened, whether or not
the
form is submitted.
你看到了if / end if吗?他回应的部分内容?那几乎已经回答了这个问题。
Did you see the "if / end if" parts of his response? That pretty much
answered the question.
这篇关于CDO.Message在页面加载时发送,但表单不提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!