I am trying to run this code but I am getting the following exception: Failure sending mail.
And my Code is given below:
try
        {
            MailMessage mail = new MailMessage("from@gmail.com", "to@gmail.com");
            SmtpClient client = new SmtpClient
            {
                Port = 465,
                UseDefaultCredentials = false,
                Host = "smtp.gmail.com",
                EnableSsl = true,
                Credentials = new NetworkCredential("from@gmail.com", "xxxxxxx")
            };
            mail.Subject = "Hello";
            mail.Body = "This is test Message";
            client.Send(mail);
        }
        catch (Exception _ex)
        {
            Debug.Write(_ex.Message);
        }
Even I turn on the 'Less secure App '
 
    