1

请帮我

我正在使用 sendMail 功能发送邮件。点击按钮我正在发送邮件。但相反,它只需单击一下就可以背靠背发送两封邮件,我找不到任何原因,所以如果有人知道这个问题,请提供帮助,感谢任何帮助,谢谢....

下面是我发送邮件的 VB 代码....

Protected Sub btnsend_Click(ByVal sender As Object, ByVal e As System.EventArgs) _ 
    Handles btnsend.Click

    'Response.Write("<Script> alert('" & Request.QueryString("id").ToString() & "');</Script>")
    Dim str_smtpserver As String = DotNetNuke.Entities.Host.HostSettings.GetHostSetting("SMTPServer")
    Dim str_auth As String = DotNetNuke.Entities.Host.HostSettings.GetHostSetting("SMTPAuthentication")
    Dim str_uname As String = DotNetNuke.Entities.Host.HostSettings.GetHostSetting("SMTPUsername")
    Dim str_pass As String = DotNetNuke.Entities.Host.HostSettings.GetHostSetting("SMTPPassword")

    Dim str_sub As String = "Message "

    Dim tobody As String

    Dim value As String = Request.QueryString("id").ToString()

    Dim ds_staff = New DataSet()

    ds_staff = DotNetNuke.Data.DataProvider.Instance().ExecuteDataSet("GetToEmailFromDB", value)
    tobody = "<table border='1px'>"

    tobody += "<tr><td style='width:90px;'>Name :</td><td>" & txtname.Text & "</td></tr>"
    tobody += "<tr><td style='width:90px;'>Email :</td><td>" & txtemail.Text & "</td></tr>"
    tobody += "<tr><td style='width:120px;'>Message :</td><td>" & txtmessage.Text & "</td></tr>"

    tobody += "</table>"

    fromid = "test@test.org"
    Dim rVal As String = DotNetNuke.Services.Mail.Mail.SendMail(fromid, ds_staff.Tables(0).Rows(0)("email").ToString(), "", "", DotNetNuke.Services.Mail.MailPriority.Normal, str_sub, DotNetNuke.Services.Mail.MailFormat.Html, System.Text.Encoding.UTF8, tobody, "", str_smtpserver, str_auth, str_uname, str_pass)
    If (rVal = "") Then
        Page.ClientScript.RegisterStartupScript(Page.GetType(), "err_msg", "alert('Your message has been sent.');", True)
    Else
        Page.ClientScript.RegisterStartupScript(Page.GetType(), "err_msg", "alert('Invalid Email ID.');", True)
    End If

    Response.Redirect("home.aspx", True)
End Sub
4

1 回答 1

0

事件处理程序很可能多次附加到按钮的单击事件。

也许您在 aspx 文件中执行一次,在 (OnInit?) 文件后面的代码中执行一次。

于 2013-06-13T12:16:54.047 回答