asp.net发送重复的电子邮件

时间:2016-02-25 05:30:32

标签: asp.net vb.net

每次点击按钮,我都会收到重复的电子邮件。我的编码有什么问题?下面是我的asp.net代码(VB.net)代码。请帮忙,谢谢

    Using sw As New StringWriter()
        Using hw As New HtmlTextWriter(sw)
            GridView2.RenderControl(hw)
            Dim sr As New StringReader(sw.ToString())
            Dim mm As New MailMessage("gmail", "gmail")
            mm.Subject = "Testing email"
            mm.Body = "Testing email <br/> <hr />" + sw.ToString() & "<br/ <br/>"
            mm.IsBodyHtml = True
            Dim smtp As New SmtpClient()
            smtp.Host = "smtp.gmail.com"
            smtp.EnableSsl = True
            Dim NetworkCred As New System.Net.NetworkCredential()
            NetworkCred.UserName = "my gmail address"
            NetworkCred.Password = "my password"
            smtp.UseDefaultCredentials = True
            smtp.Credentials = NetworkCred
            smtp.Port = 587
            smtp.Send(mm)
            End Using
    End Using

0 个答案:

没有答案