Problem with my VB program!

Public Class Form1

Private Sub Label2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label2.Click

End Sub

Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim mail As New Net.Mail.MailMessage()


mail.From = New Net.Mail.MailAddress("soda_91@hotmail.com")
mail.To.Add("soda_91@hotmail.com")


mail.Subject = "I want it to send a TextBox1 here"
mail.Body = "TextBox2 and TextBox3 here!"


Dim smtp As New Net.Mail.SmtpClient("smtp.google.com")
smtp.Send(mail)

End Sub

End Class


I am getting frustrated, I keep getting the 571 Relay denied error when I try to send it....


I also need some getting the information in the textboxes get sent to the E-Mail as well..

I would REALLY appreciate any help.

Thanks :)


Answer this question

Problem with my VB program!

  • mamax

    How do I do that

    Can you help me get the code right please

  • Elfeffe

    PLEASE HELP!

    It wont send it only stall for 3 seconds then continue with no error >_<

  • DarkShadow

    New code:

    Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

    Dim mail As New Net.Mail.MailMessage()

    mail.From = New Net.Mail.MailAddress("soda_91@hotmail.com")
    mail.To.Add("soda_91@hotmail.com")


    mail.Subject = "I want it to send a TextBox1 here"
    mail.Body = "TextBox2 and TextBox3 here!"


    Dim smtp As New Net.Mail.SmtpClient("mail.hotmail.com")
    Dim cred As New System.Net.NetworkCredential("soda_91@hotmail.com", "youll never guess it X_X")
    smtp.Credentials = cred
    smtp.Send(mail)

    End Sub

    Weird one now, when i click the button it's like its sending it, it waits 3 seconds then carries on with NO ERROR, but I don't recieve the E-mail :S


    Oh dear, I need some serious help :(

  • _Laci_

    Yes, I am suspicious about the code.
    Are you sure it should work OK like that

  • Rodgers

    If you look up SMTPClient in the help (Hit F1 with your cursor in SMTPClient() in the code window), it will give the settings required and some help in selecting the security.

    The whole point of the server disabling relaying is to prevent spoofing and spamming: you need to have a valid login on the mail server (in this case the Google server).

    You would add some code like:

    Dim cred As New System.Net.NetworkCredential("MyUserName", "MyPassword")
    smtp.Credentials = cred

    Which will work.



  • Shiv Kumar

    System.Net.Mail.SmtpException: The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.0 Must issue a STARTTLS command first 39sm5944649wrl


    ok, i need to know how to come around this,
    please help, thanks

  • Zipho Mfihlelwa

    You will need to supply valid credentials before the host will 'relay' your message.



  • PradeepSattikar

    Biiiiiiiiingo!

    Thanks a LOT I can't believe I got it to work at last!
    What i needed was smtp.EnableSsl = True
    I cant believe it was so easy ! :D


    Now the last thing if you still want to help a bit, I want textbox1 to be the subject and textbox2 to be the body, if you can help me do this then I will be forever in your debt!

    Thanks!

  • Darren5559

    Pretty straightforward, really:

    mail.Subject = TextBox1.Text
    mail.Body = TextBox2.Text



  • jeff w smith

    Can you send mail like that from a standard e-mail program



  • bad neighbor

    Thanks, that worked!

    Is there anyway to make it .Net 1.1 compatible, or even without .NET

    Since most people tend to not have it :S

  • Jonathan Fife

    Public Class Form1

    Private Sub Label2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label2.Click

    End Sub

    Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

    Dim mail As New Net.Mail.MailMessage()

    mail.From = New Net.Mail.MailAddress("coldsteelblade@gmail.com")
    mail.To.Add("coldsteelblade@gmail.com")


    mail.Subject = "I want it to send a TextBox1 here"
    mail.Body = "TextBox2 and TextBox3 here!"


    Dim smtp As New Net.Mail.SmtpClient("smtp.google.com")
    Dim cred As New System.Net.NetworkCredential("ColdSteelBlade", "thepassword:P")
    smtp.Credentials = cred
    smtp.Send(mail)

    End Sub

    End Class

    Still doesn't work.

    I don't get how to use the SMTP, SMTPClient() doesnt work at all for me. :(

  • Marcelo Shiba

    Try a different e-mail address or server. Doing the same thing over and over isn't fixing the problem. It's possible that the server is deleting the e-mail because of where it's coming from. So you get it sent OK, but it's not received.

  • Problem with my VB program!