send email from vb.net useing gmail

Im trying to send a email using my gmail any idea why this is not working?
this is the code

    Sub SendEmail()

        Dim insMail As New MailMessage()

        insMail.Sender = New MailAddress("myemail@gmail.com")
        insMail.From = New MailAddress("myemail@gmail.com")
        insMail.To.Add(New MailAddress("myemail@yahoo.com"))
        insMail.Subject = "Testing message"
        insMail.Body = "i hope it delivered"

        Dim Smtp As New SmtpClient

        Smtp.Host = "Smtp.gmail.com"
        Smtp.Port = 587
        Smtp.EnableSsl = True
        Smtp.Credentials = New Net.NetworkCredential("myemail@gmail.com", "mypassword", "smtp.gmail.com")

        Smtp.Send(insMail)

    End Sub

and this is the error

The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required d24sm7131381and


any help?
Thanks
LVL 2
mbacsAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
vadim63Connect With a Mentor Commented:
You have to change:

Smtp.Credentials = New Net.NetworkCredential("myemail@gmail.com", "mypassword", "smtp.gmail.com")

to

Smtp.Credentials = New Net.NetworkCredential("myemail@gmail.com", "mypassword")
0
All Courses

From novice to tech pro — start learning today.