一、设置163邮箱的授权码
二、发送邮件的相关代码
using System;
using System.Net.Mail;
namespace Test
{
class Program
{
static void Main(string[] args)
{
using (MailMessage mailMessage = new MailMessage())
using (SmtpClient smtpClient = new SmtpClient("smtp.163.com"))//SMTP服务器
{
mailMessage.To.Add("888888@qq.com"); //接收邮箱
mailMessage.Body = "这里写邮件正文";//邮件正文
mailMessage.From = new MailAddress("18468003528@163.com");//发送邮箱
mailMessage.Subject = "这里写邮件标题";//邮件标题
smtpClient.Credentials = new System.Net.NetworkCredential("****@163.com","****");//参数填smtp用户名、授权码
smtpClient.Send(mailMessage);
}
Console.ReadKey();
}
}
}