zoukankan      html  css  js  c++  java
  • C#SMTP发邮件

    public static bool SendMailUse()
    {
    string host = "smtp.163.com";// 邮件服务器smtp.163.com表示网易邮箱服务器
    string userName = "enbqluqib59@163.com";// 发送端账号
    string password = "a96606";// 发送端密码(这个客户端重置后的密码)

    SmtpClient client = new SmtpClient();
    client.DeliveryMethod = SmtpDeliveryMethod.Network;//指定电子邮件发送方式
    client.Host = host;//邮件服务器
    client.UseDefaultCredentials = true;
    client.Credentials = new System.Net.NetworkCredential(userName, password);//用户名、密码

    string strfrom = userName;
    string strto = "llun96202@sina.com";
    //string strcc = "llun96202@sina.com";//抄送


    string subject = "订单标题";//邮件的主题
    string body = "订单标题";//发送的邮件正文

    System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage();
    msg.From = new MailAddress(strfrom, "订单");
    msg.To.Add(strto);
    //msg.CC.Add(strcc);

    msg.Subject = subject;//邮件标题
    msg.Body = body;//邮件内容
    msg.BodyEncoding = System.Text.Encoding.UTF8;//邮件内容编码
    msg.IsBodyHtml = true;//是否是HTML邮件
    msg.Priority = MailPriority.High;//邮件优先级

    try
    {
    client.Send(msg);
    return true;
    }
    catch (System.Net.Mail.SmtpException ex)
    {
    return false;
    }
    }

  • 相关阅读:
    win 10安装 wamp 丢失msvcr110.dll 解决办法
    技巧——快读快写
    考前一些复习东东
    2019.11月4日模拟赛(早)
    2019 年 10 月训练赛(10.30早)
    2019 年 10 月训练赛(10.30晚)
    NOIP 鸡王争霸赛
    2019 10.3模拟
    CSP考纲及高精度计算
    CCF 全国信息学奥林匹克联赛复赛模拟
  • 原文地址:https://www.cnblogs.com/ChiYue/p/8452262.html
Copyright © 2011-2022 走看看