mail.To
and mail.From
are readonly. Move them to the constructor.
using System.Net.Mail;
...
MailMessage mail = new MailMessage("[email protected]", "[email protected]");
SmtpClient client = new SmtpClient();
client.Port = 25;
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.UseDefaultCredentials = false;
client.Host = "smtp.gmail.com";
mail.Subject = "this is a test email.";
mail.Body = "this is my test email body";
client.Send(mail);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…