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  
  • 相关阅读:
    js布尔型
    C#函数(十一)
    JavaScript+jQuery从小工到专家学习笔记数值
    C#函数(十)
    C#函数(九)
    jquery 操作复选框 下拉框
    jquery select操作大全
    Jquery与Json实现Ajax
    如何打造创业团队
    jquery select操作大全
  • 原文地址:https://www.cnblogs.com/hugeboke/p/11574850.html
Copyright © 2011-2022 走看看