//1、发送邮件的客户端对象
SmtpClient smpt = new SmtpClient("smtp.qq.com");
//9、邮件客户端证书
smpt.EnableSsl = true;
smpt.UseDefaultCredentials = false;
smpt.Credentials = new System.Net.NetworkCredential("qq邮箱号码", "ysmlngpjphlrbgaa--邮箱的激活码");
//4、邮件发出地址
MailAddress from = new MailAddress("723110105@qq.com", "显示发送者的名字", Encoding.UTF8);
//5、邮件接收地址
MailAddress to = new MailAddress("收件人的邮箱地址");
//3、创建MailMessage对象
MailMessage mess = new MailMessage(from, to);

//8、验证码创建

string str = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
string YZM = "";

Random r = new Random();

for (int i = 0; i < 6; i++)
{
YZM += str.Substring(r.Next(0, str.Length), 1);
}

//6、发送邮件的标题
mess.Subject = "标题内容";
//7、发送邮件的内容
mess.Body = "来自**的邮箱验证码为【"+YZM +"】,此邮件位系统邮件,勿回复!!!";

//2、发送邮件(调用客户端对象里的发送方法)
smpt.Send(mess);