I wrote the following code to send an email
private void btnMail_Click(object sender, EventArgs e)
{
try
{
MailMessage Msg = new MailMessage();
Msg.From = new MailAddress("sender@gmail.com");
Msg.To.Add(reciver@gmail.com);
Msg.Subject = "One Time Password";
Msg.Body = "Your One Time Password is: " + txtOTC.Text.Trim();
Msg.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.gmail.com";
smtp.Port = 587;
smtp.Credentials = new System.Net.NetworkCredential("sender@gmail.com", "lab");
smtp.EnableSsl = true;
smtp.Send(Msg);
MessageBox.Show(("Your OTP sent Successfully..."), "Thank you", MessageBoxButtons.OK, MessageBoxIcon.Information);
//txtEmail.Clear();
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
I have entered the correct login details but it showing me an error. hereby screenshot is attached.
how to fix this issue?