【发布时间】:2016-10-12 11:33:08
【问题描述】:
我的电子邮件联系表(出于某种未知原因)发送了两次,有时甚至发送了三次,尽管这种情况很少见。
这是我的 VB:
<% @Import Namespace="System.Web.Mail" %>
<script language="vb" runat="server">
Sub btnSendFeedback_Click(sender as Object, e as EventArgs)
Dim objMM as New MailMessage()
objMM.To = "info@emailaddress.com"
objMM.From = txtEmail.Text
'objMM.Cc = "someone@someaddress.com"
'objMM.Bcc = "someone@someaddress.com"
objMM.BodyFormat = MailFormat.Text
objMM.Priority = MailPriority.Normal
objMM.Subject = "Scotts Holiday Village"
objMM.Body = "Hello. At " + DateTime.Now + " an initial enquiry " & _
"was made " & _
"by a: " & txtTitle.Text & " " & txtFName.Text & " " & txtLName.Text & "." & vbCrLf & vbCrLf & _
""& txtAdOne.Text & vbCrLf & _
txtAdTwo.Text & vbCrLf & _
txtAdThree.Text & vbCrLf & _
""& txtCity.Text & vbCrLf & _
""& txtPostCode.Text & vbCrLf & vbCrLf & _
"Phone number: " & vbCrLf & txtPhone.Text & vbCrLf & vbCrLf & _
"Email address: " & vbCrLf & txtEmail.Text & vbCrLf & vbCrLf & _
"When are you looking to buy?: " & vbCrLf & txtWhenBuy.Text & vbCrLf & vbCrLf & _
"Estimated budget: " & vbCrLf & txtEstBudget.Text & vbCrLf & vbCrLf & _
"What's given you the idea of buying?: " & vbCrLf &txtIdea.Text & vbCrLf & vbCrLf & _
"Message: " & vbCrLf &txtMsg.Text & vbCrLf
SmtpMail.SmtpServer = "smtp.1and1.com"
SmtpMail.Send(objMM)
panelSendEmail.Visible = false
panelMailSent.Visible = true
End Sub
</script>
panelMailSent 重定向到谢谢,确认页面可能与它有关,我不确定:
<asp:panel id="panelMailSent" runat="server" Visible="False">
<% Response.Redirect("/thankyou/message-sent.aspx") %>
</asp:panel>
提交按钮:
<asp:Button runat="server" ID="btnSendFeedback" Text="Send my form"
OnClick="btnSendFeedback_Click" />
表单方法:
<form method="post" id="genericForm" action="default.aspx" name="installer" onsubmit="showHide(); return false;">
非常感谢。
【问题讨论】:
-
总是发送两次吗?有人会多次按下按钮吗?
-
嗨@David_001 - 这是可能的,但希望他们能快速进入确认页面。有没有办法我可以“禁用”它,第二轮(如果按下)?
-
在这个方法中放一个断点,检查两个调用的调用栈
-
嗨@ArsenMkrtchyan,你介意解释一下你的意思吗,我对.Net比较陌生:-)
标签: asp.net vb.net forms email