zoukankan      html  css  js  c++  java
  • .NET 发送邮件

    //邮件配置
    public static string mail_smtp = System.Configuration.ConfigurationManager.AppSettings["mail_smtp"];
    public static string mail_main = System.Configuration.ConfigurationManager.AppSettings["mail_main"];
    public static string mail_pwd = System.Configuration.ConfigurationManager.AppSettings["mail_pwd"];
    public static int mail_port = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["mail_port"]);
    public static string mail_ssl = System.Configuration.ConfigurationManager.AppSettings["mail_ssl"];

    /// <summary>
    /// 发送邮件1
    /// </summary>
    /// <param name="AcceptEmail"></param>
    /// <param name="sendText"></param>
    public static void SendEmail(string AcceptEmail, string sendText, string SendTitle)
    {
    SendSMTPEMail(mail_smtp, mail_main, mail_pwd, AcceptEmail, SendTitle, sendText);
    }
    /// <summary>
    /// 发送邮件2
    /// </summary>
    /// <param name="strSmtpServer"></param>
    /// <param name="strFrom"></param>
    /// <param name="strFromPass"></param>
    /// <param name="strto"></param>
    /// <param name="strSubject"></param>
    /// <param name="strBody"></param>
    public static void SendSMTPEMail(string strSmtpServer, string strFrom, string strFromPass, string strto, string strSubject, string strBody)
    {
    SmtpClient client = new SmtpClient(strSmtpServer);
    client.UseDefaultCredentials = false;
    client.Credentials = new System.Net.NetworkCredential(strFrom, strFromPass);
    client.DeliveryMethod = SmtpDeliveryMethod.Network;
    client.Port = mail_port;
    client.EnableSsl = mail_ssl == "yes";

    MailMessage message = new MailMessage(strFrom, strto, strSubject, strBody);
    message.BodyEncoding = System.Text.Encoding.UTF8;
    message.IsBodyHtml = true;
    client.Send(message);
    }

  • 相关阅读:
    Oracle使用笔记
    跳转至锚点
    项目中使用到的AOP
    短信验证码接口使用
    阿里人脸识别接口
    java实现网页截图
    java后台接收微信服务号/订阅号消息
    java 实现redis缓存
    redis 常用命令
    被骗了,自己还不知道
  • 原文地址:https://www.cnblogs.com/xsj1989/p/4811363.html
Copyright © 2011-2022 走看看