//创建邮箱信息
MailMessage myMail = new MailMessage();//声明一个mail对象
myMail.Priority = MailPriority.High;//设置邮件等级为high
myMail.From = new MailAddress("发件人邮箱", "发件人名称");//发件人地址
myMail.To.Add(new MailAddress("收件人邮箱", "收件人名称");//收件人地址
myMail.Subject = "主题";//主题
//发送的内容
myMail.Body ="发送邮件的内容";//发送邮件的内容
//创建一个邮件服务器类
SmtpClient myclient = new SmtpClient();
myclient.Host = "SMTP.163.com";//设置服务器的ip地址,还可以是smtp.qq.com等等
myclient.Port = Convert.ToInt32("");//设置服务器的端口号
//验证登陆 设置发送人和密码
myclient.Credentials = new NetworkCredential("发件人邮箱", "发件人邮箱密码");
//发送邮件
try
{
myclient.Send(myMail);
return true;
}
catch (Exception)
{
return false;
}