using System; using System.Collections.Generic; using System.Linq; using System.Net.Mail;//发送邮箱 using System.Text; using System.Threading.Tasks; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { MailMessage mm = new MailMessage();//信 mm.Priority = MailPriority.High; mm.To.Add("1024477951@qq.com");//收信邮箱 //mm.CC.Add();//抄送 mm.From = new MailAddress("1024477951@163.com");//发信邮箱 //mm.Attachments.Add(new Attachment(文件名))//文件附件 mm.Subject = "测试"; mm.BodyEncoding = Encoding.UTF8; mm.Body = " <a href='http://localhost:3255/ReceiveMail.aspx?id=11'>请假</a>";//定义信的内容 mm.IsBodyHtml = true;//设置内容为html格式 // Smtp:简单邮件传输协议,发邮件 POP3 收邮件 SmtpClient sc = new SmtpClient(); sc.DeliveryMethod = SmtpDeliveryMethod.Network;//设置邮件通过网络发送 sc.Host = "smtp.163.com";//设置邮件服务地址 sc.Credentials = new System.Net.NetworkCredential("1024477951", "123");//验证发件人身份,"123abc"是发件人密码s sc.Send(mm); Console.WriteLine("发送成功!"); } } }