试试这段代码测试OK
private void SenEmail()
{
string mailServerName = "smtp.qq.com"; //发送邮件的SMTP服务器
string mailFrom = "123456789@qq.com"; //发件人邮箱(用126的邮件服务器,就必须用126邮箱的用户名)
//收信人邮箱
string mailTo = "123456@163.com"; //收件人邮箱
string subject = "测试"; //邮件主题
string body = "测试发送"; //邮件正文
using (MailMessage message = new MailMessage(mailFrom, mailTo, subject, body))
{
SmtpClient mailClient = new SmtpClient(mailServerName);
mailClient.Credentials = new NetworkCredential("123456789@qq.com", "123456789");//发件邮箱的用户名和密码
mailClient.Send(message);
}
}