I’m trying to send emails through Gmail’s SMTP server using VB.NET but keep getting errors. The email never gets delivered and I’m not sure what’s wrong with my setup.
Here’s my current code:
Private Sub sendButton_Click(sender As Object, e As EventArgs) Handles sendButton.Click
Dim mailClient As New SmtpClient("smtp.gmail.com", 587)
mailClient.Credentials = New Net.NetworkCredential("[email protected]", "mypassword")
Dim message As New MailMessage("[email protected]", "[email protected]", "Test Subject", "Message content")
mailClient.Send(message)
End Sub
I’ve checked my credentials multiple times and they’re correct. Has anyone experienced similar problems with Gmail SMTP in VB.NET? What could be causing this issue?
omg, i faced this too! yeah, ur right. gotta use an app-specific password now, regular ones won’t work anymore. just go to security settings and create one but make sure 2FA is on or u won’t see the option. good luck!
To successfully send emails via Gmail’s SMTP in VB.NET, ensure that you have enabled SSL/TLS. You can do this by adding mailClient.EnableSsl = True
right after setting your credentials. Additionally, since Gmail no longer allows regular passwords for SMTP access, you’ll need to use an App Password generated from your Google Account security settings. I encountered the same issue last year and it took some time to resolve because of the App Password requirement. Once you have both SSL enabled and use the App Password, your emails should go through without issues.
It’s definitely your authentication method. Gmail killed basic auth for SMTP ages ago, so your regular password won’t work even if it’s right. You need to create an App Password in your Google Account settings (under Security). But first, make sure you’ve got two-factor auth turned on - you can’t generate App Passwords without it. Once you have the App Password, swap out your regular password with it in the NetworkCredential line. And don’t forget to set EnableSsl to True since Gmail requires encrypted connections. I hit this same wall when migrating an old app - super frustrating until I figured out they’d changed the auth requirements.