Welcome to Dream.In.Code
Getting Help is Easy!

Join 132,689 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,319 people online right now. Registration is fast and FREE... Join Now!




Email Generates Twice, Not Sure why

 
Reply to this topicStart new topic

Email Generates Twice, Not Sure why

ivanjay205
post 19 Sep, 2008 - 11:37 AM
Post #1


New D.I.C Head

*
Joined: 3 Sep, 2008
Posts: 8

I wrote a VB sub to run behind a submit button so that when a user hits submit, the asp code generates an email and sends to a user.

Here is the code from the vb file

CODE
Protected Sub SendButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles SendButton.Click

        Dim emailFrom As String
        Dim emailTo As String = "ivan.weiss@elitefse.com"
        Dim emailSubject As String = "Project Work Request"
        Dim emailBody As String
        Dim emailClient As New Mail.SmtpClient("207.41.178.150", 25)

        Select Case RequesterNameDropDownBox.SelectedValue
            Case "Rick DiFilippi"
                emailFrom = "rdifilippi@studioedesigngroup.com"
            Case "Sheron Makara"
                emailFrom = "sheron.makara@elitefse.com"
            Case "Craig Marshall"
                emailFrom = "craig.marshall@elitefse.com"
            Case "Josh Mass"
                emailFrom = "joshua.mass@elitefse.com"
            Case "Mike Simonds"
                emailFrom = "mike.simonds@elitefse.com"
            Case "Mike Watson"
                emailFrom = "michael.watson@elitefse.com"
            Case "Eric Weiss"
                emailFrom = "eric.weiss@elitefse.com"
            Case "Ivan Weiss"
                emailFrom = "ivan.weiss@elitefse.com"
            Case "Vijaye Yarna"
                emailFrom = "vijaye.yarna@elitefse.com"
            Case Else
                emailFrom = "ivan.weiss@elitefse.com"
        End Select

        emailBody = "<p><h2>Client</h2></p><p>Company:  " & ClientCompanyTextBox.Text & "</p><p>Address1:  " & ClientAddress1TextBox.Text & "</p><p>Address2:  " & ClientAddress2Textbox.Text & "</p><p>Phone:  " & ClientPhoneTextBox.Text & "</p><p>Email:  " & ClientEmailTextBox.Text & "</p><p><h2>Architect</h2></p><p>Company:  " & ArchitectCompanyTextBox.Text & "</p><p>Address1:  " & ArchitectAddress1TextBox.Text & "</p><p>Address2:  " & ArchitectAddress2TextBox.Text & "</p><p>Phone:  " & ArchitectPhoneTextBox.Text & "</p><p>Email:  " & ArchitectEmailTextBox.Text & "</p>"
        Try
            Dim emailMessage As New Mail.MailMessage(emailFrom, emailTo, emailSubject, emailBody)
            'Dim emailMessage As New Mail.MailMessage(emailFrom, emailTo)

            emailMessage.IsBodyHtml = True
            emailMessage.Body = emailBody
            emailMessage.Subject = emailSubject

            emailClient.DeliveryMethod = Mail.SmtpDeliveryMethod.Network
            emailClient.Send(emailMessage)
            MsgBox("Email successfully sent.", MsgBoxStyle.Information, "Email Success")
            Exit Sub
        Catch ex As Exception
            MsgBox("Error in sending email.  See System Administrator.", MsgBoxStyle.Critical, "Email Failure")
            Exit Sub
        End Try
    End Sub


Here is the code in the button calling this:

CODE
<div>
        <asp:Button ID="SendButton" Text="Send"
            ToolTip="Click to send project request form" runat="server"
            onclick="SendButton_Click" TabIndex="13" Width="165px" />
    </div>


Any ideas?
User is offlineProfile CardPM

Go to the top of the page

rollout369
post 23 Oct, 2008 - 06:10 AM
Post #2


New D.I.C Head

*
Joined: 17 Oct, 2008
Posts: 6

I have the same issue. Did you find a fix for it?
User is offlineProfile CardPM

Go to the top of the page

PsychoCoder
post 23 Oct, 2008 - 06:20 AM
Post #3


using DIC.Core;

Group Icon
Joined: 26 Jul, 2007
Posts: 8,933



Thanked 118 times

Dream Kudos: 8525

Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net

My Contributions


I think I have a solution for you, the send is actually being called twice because in your button's click event you have Handles SendButton.Click and in the buttons markup you have onclick="SendButton_Click" . Try removing either of those and see if your problem goes away smile.gif
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 11/23/08 07:36AM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month