zoukankan      html  css  js  c++  java
  • 发送邮件(公共方法)

      #region 发送邮件
    
            public bool Send(string email, string title, string body)
            {
                string message="发送成功";
    
                return Send(email, title, body, out message);
            }
    
            public bool Send(string email, string title, string body,out string message)
            {
                message = "发送成功";
    
                bool returnValue = true;
                try
                {
                    System.Web.Mail.MailMessage myEmail = new System.Web.Mail.MailMessage();
                    myEmail.From = FromEmail;
                    myEmail.To = email;
                    myEmail.Subject = title;
                    myEmail.Body = body;
    
                    myEmail.BodyFormat = System.Web.Mail.MailFormat.Html; //邮件形式,.Text、.Html 
    
                    // 通过SMTP服务器验证
    
    
                    if (!string.IsNullOrEmpty(UserName))
                    {
                        myEmail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1"); //basic authentication
                        myEmail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", UserName); //set your username here
                        myEmail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", Password); //set your password here
                    }
    
    
                    System.Web.Mail.SmtpMail.SmtpServer = SmtpServer;
                    //System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient();
    
                    System.Web.Mail.SmtpMail.Send(myEmail);
    
                }
                catch (Exception e)
                {
                    message = e.ToString();
                    returnValue = false;
                    logger.Error(e.ToString());
                }
    
                return returnValue;
            }
           #endregion  
  • 相关阅读:
    oracle分区表总结
    Oracle AMDU用法
    sql_patch用法
    oracle resource_managed限制个人用户使用并行
    oracle 服务的故障转移测试
    RAC修改public ip,vip,priv_ip,sacn_ip
    oracle tfactl使用 TFA
    oracle dbms_metadata.get_ddl使用总结
    Oracle分析函数总结
    继承与接口的区别
  • 原文地址:https://www.cnblogs.com/hugeboke/p/11574850.html
Copyright © 2011-2022 走看看