Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

web form sending two emails out, only should send one.

Status
Not open for further replies.

Steel811

Programmer
Jan 2, 2008
26
US
Hello,

I am new to coding in vb.net and have run into an issue with some code
that I am looking over. This is a webform that is filled out and once
it is filled out, it takes the responses from the form and appends it
to an email which it then sends out to one specific user (for testing
purposes, it's sending to me). My problem is that the code somehow is
sending two identical emails to me. I am almost certain that the code
looks ok, and I have other applications written in vbscript that sends
to the same relay server and only sends out one email. Can anyone else
see why this might be happening?


Thanks in advance,
Sheel Shah
Society of Actuaries


Dim emailfrom As String = ""
Dim emailto As String = ""
Dim emailcc As String = ""
Dim emailsubject As String = ""
Dim attachmentfile As String = ""
Dim is_attached As Boolean = True
Dim save_filepath As String = ""


emailfrom =
System.Configuration.ConfigurationManager.AppSettings("ExpressionOfInterest­_Email_From")


emailto = "ss...@soa.org"
emailsubject =
System.Configuration.ConfigurationManager.AppSettings("ExpressionOfInterest­_Subject")


Dim message As System.Net.Mail.MailMessage
Dim emailClient As SmtpClient


Dim messageBody = msg.ToString()


Try
message = New MailMessage(emailfrom, emailto, "College
Listing Application Form", msg.ToString())
If (emailcc.ToString.Trim <> "") Then
message.CC.Add(emailcc)
End If
emailClient = New
SmtpClient(System.Configuration.ConfigurationManager.AppSettings("mail.serv­er.name").ToString,
System.Configuration.ConfigurationManager.AppSettings("mail.server.port"))
emailClient.Send(message)
lblerrmsg.text = "Your College Listing Application
Form has been successfully sent."
confirmation.Visible = True
MainForm.Visible = False


Catch ex As Exception
lblerrmsg.Text = "Your Form is not Submitted.
Please contact web Administrator for this Error."
confirmation.Visible = False
MainForm.Visible = True
Finally


End Try

Thanks,
Sheel
 
have you tried checking to see that the script is not being called 2x's for some reason?
What event are you calling this on?

If [blue]you have problems[/blue], I want [green]source code[/green] AND [green]error messages[/green], none of this [red]"there was an error crap"[/red]
 
I can't see anywhere that it is calling the send command twice.

It generates the email based on the responses in the web form just above the code I've attached, and then sends it out when the user clicks the "submit" button on the web form.

Thanks,
Sheel
 
Have you tried setting a breakpoint in your code and walking through it line by line to see what is happening? Perhaps there is a recursive call somewhere you have missed.

=======================================
People think it must be fun to be a super genius, but they don't realize how hard it is to put up with all the idiots in the world. (Calvin from Calvin And Hobbs)

Robert L. Johnson III
CCNA, CCDA, MCSA, CNA, Net+, A+, CHDP
VB.NET Programmer
 
If it's webform you're not really going to be able to debug, but you can do some response.writes, that say something like "Sending mail"

you may need to use a boolean flag that says "i sent already, so don't send again"

If [blue]you have problems[/blue], I want [green]source code[/green] AND [green]error messages[/green], none of this [red]"there was an error crap"[/red]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top