smtp发送邮件

  MailMessage mm = new MailMessage();//创建邮件对象
        mm.IsBodyHtml = true;
        mm.Body = "";//邮件正文
        mm.BodyEncoding = System.Text.Encoding.UTF8;
        mm.From = new MailAddress("");//发件人地址
        mm.Subject = title;
        mm.To.Add("");//收件人地址
        SmtpClient sc = new SmtpClient();//邮箱协议对象
        sc.DeliveryMethod = SmtpDeliveryMethod.Network;//设置邮件通过网络发送
        sc.Host = "smtp.163.com";//设置通信服务地址
        sc.Credentials = new System.Net.NetworkCredential("发件人地址", "123abc");//验证发件人身份,"123abc"是发件人密码s

        sc.Send(mm);

你可能感兴趣的:(smtp)