c#向指定的邮箱发送邮件
2024-10-06 17:22:18
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 = ; 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;
}
}
最新文章
- Linux平台 Oracle 11gR2 RAC安装Part3:DB安装
- 基于TXT文本的简单图书管理系统
- centos7 docker zookeeper
- php生成对象的研究
- UART IP和UVM的验证平台
- easyui combobox 中实现 checkbox
- 复利计算v6.0--web版--软件工程
- Ubuntu 14.04的vim编辑器配置Python开发环境
- 【nodejs】使用Node.js实现REST Client调用REST API
- IE7和IE8出现的计算判断问题
- RabbitMQ资料
- PHP中高级进阶之路
- 小程序之hover-class
- request.getRequestDispatcher 页面跳转,样式丢失。
- Exchange Online Mailbox Restoration
- 【转】如何基于linux进程通信设计方案
- luogu2607/bzoj1040 [ZJOI2008]骑士 (基环树形dp)
- 【BZOJ】1052: [HAOI2007]覆盖问题
- 力扣(LeetCode)7.整数反转
- UVa 10795 - A Different Task 对称, 中间状态, 数位DP 难度: 3