The sample is using C#.
SmtpClient client = new SmtpClient();
client.Host = "smtp.gmail.com";
client.Port = 587;
client.UseDefaultCredentials = false;
client.Credentials = new System.Net.NetworkCredential(stFromUserName, stFromPassword);
client.EnableSsl = true;
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.Send(mail);
You'll also need to go here and enable less secure apps.
Or if you have two step authentication on your account you'll need to set an app specific password, then use that password in your code instead of your main account password.
Thanks to equalsk
Reference :
