zoukankan      html  css  js  c++  java
  • c#向指定的邮箱发送邮件

     private bool SendEmail(string fileName)
            {
                MailMessage m_Mail = new MailMessage();
                m_Mail.From = new MailAddress(ConfigurationManager.AppSettings["MailFrom"]);
                string m_MailToStr = ConfigurationManager.AppSettings["MailTo"];
                string m_MailServer = ConfigurationManager.AppSettings["MailServer"];
                string[] m_MailToList = m_MailToStr.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                for (int i = 0; i < m_MailToList.Length; i++)
                {
                    m_Mail.To.Add(new MailAddress(m_MailToList[i]));
                }
                m_Mail.Subject = "Pending Fund List";
                m_Mail.Body = "Please find the attachment for the Pending Funds List while it is ID, OP & Perf ready. ";
                m_Mail.IsBodyHtml = true;
                m_Mail.BodyEncoding = System.Text.Encoding.UTF8;
                Attachment m_MailAttach = null;
                if (!string.IsNullOrEmpty(fileName))
                {
                    m_MailAttach = new Attachment(fileName);
                    m_Mail.Attachments.Add(m_MailAttach);
                }
                SmtpClient client = new SmtpClient(m_MailServer);
                try
                {
                    client.Send(m_Mail);
                    if (m_MailAttach != null)
                        m_MailAttach.Dispose();
                    return true;
                }
                catch (Exception e)
                {
                    //_log.Error(e.Message);
                    return false;
                }
            }
  • 相关阅读:
    scrapy 随机UserAgent
    Scrapy使用中间件捕获Spider抛出的异常
    10.16-arrarylist
    10.15_package_2
    10.14_package_1
    10.13_enum_2
    10.12-enum_1
    10.11-java的接口2
    10.10-3对象和类_动手动脑-java的接口
    10.9-java的封装
  • 原文地址:https://www.cnblogs.com/mibing/p/7845701.html
Copyright © 2011-2022 走看看