I get this error trying to send a message in VB.Net via Gmail:

enter image description here

after attempting to send a message, my google account in device/website has logged out and asking for verification for unusual activity (which is sending message in vbnet 2010).

This is my source code ↓ ↓ ↓

Try

    Dim smtpserver As New SmtpClient()
    Dim mail As New MailMessage()

    smtpserver.Credentials = New Net.NetworkCredential(emailFrom, passW)
    smtpserver.Port = 465 ' 587 alternate
    smtpserver.Host = "smtp.gmail.com"
    smtpserver.EnableSsl = True

    mail = New MailMessage()
    mail.From = New MailAddress(emailFrom)
    mail.To.Add(emailTo)
    mail.Subject = "Subject"
    mail.Body = "hello 2024"

    smtpserver.Send(mail)
    MsgBox("Mail Sent")

Catch ex As Exception

    MsgBox(ex.ToString)
    Close()

End Try

Is it possible because of 2nd-authentication of the Gmail account? how can I possibly resolve this?

0

There are 0 best solutions below