Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. ASP.NET
  4. Why this program run twice before terminate?

Why this program run twice before terminate?

Scheduled Pinned Locked Moved ASP.NET
csharpdesignquestion
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    BabyOreo
    wrote on last edited by
    #1

    halo.. I want to send email to my account but this program run twice. So,after click on submit button, 2 same mails send to my account.How this could happen? Thanks. <code><small>Imports System.Net.Mail Partial Class _Default Inherits System.Web.UI.Page Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit.Click Try Dim message As New MailMessage(txtTo.Text, txtFrom.Text, txtSubject.Text, txtBody.Text) Dim emailClient As New SmtpClient(txtSMTPServer.Text) emailClient.Send(message) litStatus.Text = "Message Sent" Catch ex As Exception litStatus.Text = ex.ToString() End Try End Sub

    E A 2 Replies Last reply
    0
    • B BabyOreo

      halo.. I want to send email to my account but this program run twice. So,after click on submit button, 2 same mails send to my account.How this could happen? Thanks. <code><small>Imports System.Net.Mail Partial Class _Default Inherits System.Web.UI.Page Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit.Click Try Dim message As New MailMessage(txtTo.Text, txtFrom.Text, txtSubject.Text, txtBody.Text) Dim emailClient As New SmtpClient(txtSMTPServer.Text) emailClient.Send(message) litStatus.Text = "Message Sent" Catch ex As Exception litStatus.Text = ex.ToString() End Try End Sub

      E Offline
      E Offline
      eyeseetee
      wrote on last edited by
      #2

      There seems to be nothing wrong with the code above. Can you check it with another e-mail address, plus possible post anymore code you have for that page cheers

      1 Reply Last reply
      0
      • B BabyOreo

        halo.. I want to send email to my account but this program run twice. So,after click on submit button, 2 same mails send to my account.How this could happen? Thanks. <code><small>Imports System.Net.Mail Partial Class _Default Inherits System.Web.UI.Page Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit.Click Try Dim message As New MailMessage(txtTo.Text, txtFrom.Text, txtSubject.Text, txtBody.Text) Dim emailClient As New SmtpClient(txtSMTPServer.Text) emailClient.Send(message) litStatus.Text = "Message Sent" Catch ex As Exception litStatus.Text = ex.ToString() End Try End Sub

        A Offline
        A Offline
        Anoop Brijmohun
        wrote on last edited by
        #3

        hi, put your code within the If Not IsPostBack Then Dim message As New MailMessage(txtTo.Text, txtFrom.Text, txtSubject.Text, txtBody.Text) Dim emailClient As New SmtpClient(txtSMTPServer.Text) emailClient.Send(message) litStatus.Text = "Message Sent" END IF hope this helps...

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups