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;
                }
            }
  • 相关阅读:
    github提交代码403
    针对七牛含有特殊字符的文件名,对特殊字符编码处理
    去除字符串所有空格
    按关键词匹配度排序
    服务器监控-Zabbix
    数据同步
    字符串-占位符
    Redis序列化
    Redis监听回调
    时间计算
  • 原文地址:https://www.cnblogs.com/mibing/p/7845701.html
Copyright © 2011-2022 走看看