gmail uses port 587
oClient.Port = 587;
You may also want to set UseDefaultCredentials
to false and explicitly declare username and password. By declaring it to be true, you are trying to log into your gmail account using your windows credentials.
oClient.UseDefaultCredentials = false;
oClient.Credentials = new NetworkCredential("[email protected]", "password");
Also, in gmail security, you will need to allow Less Secure Applications.
Finally, you need to change how your Mail.To is populated:
oMail.To.Add(new MailAddress(txtTo.Text.Trim()));
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…