zoukankan      html  css  js  c++  java
  • C#使用Smtp,通过qqmail发送邮件

    public static void SendEMail(string senderEmail, string senderAuthCode, string smtpHost, int smtpPort,
    string receiverEmail, string subject, string body)
    {
    MailMessage msg = new MailMessage();
    msg.To.Add(receiverEmail);
    //msg.To.Add(b@b.com);
    //msg.CC.Add("c@c.com");可以抄送给多人

    msg.From = new MailAddress(senderEmail);
    msg.Subject = subject;
    msg.SubjectEncoding = System.Text.Encoding.UTF8;
    msg.Body = body;
    msg.BodyEncoding = System.Text.Encoding.UTF8;
    msg.IsBodyHtml = false;
    msg.Priority = MailPriority.High;
    SmtpClient client = new SmtpClient();
    client.Credentials = new NetworkCredential(senderEmail, senderAuthCode);//senderAuthCode不是qq邮箱登录密码,需要在qq邮箱,设置>账户>smtp...,生成授权码
    client.Port = smtpPort;//QqMail:587(注意:465是无效的)
    client.Host = smtpHost;// "smtp.qq.com";
    client.EnableSsl = true;//经过ssl加密
    client.Send(msg);
    }

  • 相关阅读:
    php-管理变量
    php-变量的间接引用
    php-eval()
    HTML
    php观
    笔记1
    脚本语言
    Windows Server 2012如何把快捷方式加到启动文件夹中
    VIM的笔记
    mongodb 从3.0 升级到3.2
  • 原文地址:https://www.cnblogs.com/erentec/p/11066226.html
Copyright © 2011-2022 走看看