Results 1 to 11 of 11

Thread: send mail wierd

  1. #1

    Thread Starter
    Fanatic Member d2005's Avatar
    Join Date
    Aug 2005
    Location
    ireland
    Posts
    620

    send mail wierd

    i have an insert statement on a btn submit comp
    this works great

    i also have code to send an email,
    not sure if it works

    when i call my fuction to send the email in my btn send
    the email doesnt send and the insert doesnt insert

    how messed up is that
    it works 60% of the time, all the time.

  2. #2
    Addicted Member
    Join Date
    Aug 2004
    Location
    Cape Town, South Africa
    Posts
    149

    Re: send mail wierd

    so you got some code for us to look at? any error messages?

  3. #3

    Thread Starter
    Fanatic Member d2005's Avatar
    Join Date
    Aug 2005
    Location
    ireland
    Posts
    620

    Re: send mail wierd

    no error messages

    my code for submit is just a basic insert satatement
    then

    i call my send mail function


    Private Sub CompRegConfirmation()
    Dim msg As New MailMessage
    msg.From = "[email protected]"
    msg.To = "[email protected]"
    msg.Bcc = "[email protected]"
    msg.Subject = " Company registered"
    msg.Body = "this is a test"
    msg.Body = "helo good mornin vietnam"
    msg.BodyFormat = MailFormat.Html
    SmtpMail.SmtpServer = "localhost"
    SmtpMail.Send(msg)
    End Sub

    so id my submit click i have

    insert.........
    connection close()

    compregconfirmation()

    end sub

    if i do this then no erors appear, no insert to database, and no email is sent either
    it works 60% of the time, all the time.

  4. #4
    Fanatic Member
    Join Date
    Jun 2005
    Posts
    625

    Re: send mail wierd

    Can you post the insert statement?

  5. #5

    Thread Starter
    Fanatic Member d2005's Avatar
    Join Date
    Aug 2005
    Location
    ireland
    Posts
    620

    Re: send mail wierd

    Dim sqlInsertComp As New SqlCommand("INSERT INTO tb_comp_detail(c_companycode,c_comp_name,c_job_title,c_firstname,c_sname,c_houseno,c_street,c_passwo rd,c_town,c_county,c_country,c_comp_email,c_comp_tel,c_comp_registered,c_comp_enabled) VALUES('" & txtUsername.Text & "','" & txtCompanyName.Text & "','Owner','" & txtFirstName.Text & "','" & txtSurname.Text & "','" & txtHouseNo.Text & "','" & txtStreet.Text & "','" & txtPassword.Text & "','Derry','Derry','uk','" & txtEmailAddress.Text & "','" & txtPhoneNo.Text & "',getDate(),'0');", oSQLConn)
    oSQLConn.Open()
    sqlInsertComp.ExecuteNonQuery()
    oSQLConn.Close()
    it works 60% of the time, all the time.

  6. #6
    Fanatic Member
    Join Date
    Jun 2005
    Posts
    625

    Re: send mail wierd

    Do you catch exceptions?

  7. #7

    Thread Starter
    Fanatic Member d2005's Avatar
    Join Date
    Aug 2005
    Location
    ireland
    Posts
    620

    Re: send mail wierd

    no
    what do you suggest
    it works 60% of the time, all the time.

  8. #8
    Fanatic Member
    Join Date
    Jun 2005
    Posts
    625

    Re: send mail wierd

    Are any exceptions or errors displayed? Sometimes when I have code that doesn't do what its supposed to do and also does not display an error it is because of a caught exception.

  9. #9
    Fanatic Member
    Join Date
    Jun 2005
    Posts
    625

    Re: send mail wierd

    Is this is an ASP.NET file, or in the CodeBehind vb file? Can you post the entire methods (the _click method)

  10. #10

    Thread Starter
    Fanatic Member d2005's Avatar
    Join Date
    Aug 2005
    Location
    ireland
    Posts
    620

    Re: send mail wierd

    the code of the button submit click is just the code above
    the insert statement and then call the compregconfirmation method

    when i dont call the compregconfirmation the insert works
    if i call compregconfirmation in a different button then the email is sent ( on another machine)
    but if i try to call it in the button click event
    no insert, no email no errors
    i have no try catch statements
    it is completely baffling i know

    if you want me to post the code i will
    but its just as above
    thanks
    Last edited by d2005; Oct 6th, 2005 at 10:01 AM.
    it works 60% of the time, all the time.

  11. #11
    Fanatic Member
    Join Date
    Jun 2005
    Posts
    625

    Re: send mail wierd

    I'm just guessing at some of the basic mistakes I made when I first started vb. Just make sure the button method looks like this:

    Private Sub btnMyButton_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles btnMyButton.Click

    Make sure the btnMyButton.Click has the correct button and event name.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width