Csharp: Send Email
/// <summary>
/// 發送郵件
/// 塗聚文
/// 20130816
/// </summary>
/// <param name="to">收件人</param>
/// <param name="toName">收件人姓名</param>
/// <param name="subject">標題名</param>
/// <param name="body">內容</param>
/// <returns></returns>
public bool SendMailMessage(string to, string toName, string subject, string body)
{
bool re = false;
try
{
int id = 1;
string bcc="463588883@qq.com";
string bccName = "geovindu";
string cc = string.Empty;
string ccDisName = string.Empty; vipSetMailHostInfo = vipSetMailHostBLL.SelectVipSetMailHost(id); // Instantiate a new instance of MailMessage
MailMessage mMailMessage = new MailMessage(); // Set the sender address of the mail message
mMailMessage.From = new MailAddress(vipSetMailHostInfo.SmtpUser, vipSetMailHostInfo.SmtpName);
// Set the recepient address of the mail message
mMailMessage.To.Add(new MailAddress(to, toName)); //電子郵件,顯示名稱 //發送郵件,可以是集合列表 // Check if the bcc value is null or an empty string
if ((bcc != null) && (bcc != string.Empty))
{
// Set the Bcc address of the mail message
mMailMessage.Bcc.Add(new MailAddress(bcc, bccName));//密抄郵件
}
// Check if the cc value is null or an empty value
if ((cc != null) && (cc != string.Empty))
{
// Set the CC address of the mail message
mMailMessage.CC.Add(new MailAddress(cc, ccDisName)); //抄送郵件
} // Set the subject of the mail message
mMailMessage.ReplyTo = new MailAddress("vip@dupcit.com", "VIP客戶"); //回復信郵 //mMailMessage.ReplyTo = "VIP";
mMailMessage.Subject = subject;
// Set the body of the mail message
mMailMessage.Body = body; // Set the format of the mail message body as HTML
mMailMessage.IsBodyHtml = true;
mMailMessage.BodyEncoding = System.Text.Encoding.UTF8;// // Set the priority of the mail message to normal
mMailMessage.Priority = MailPriority.Normal; // Instantiate a new instance of SmtpClient
// SmtpClient mSmtpClient = new SmtpClient();
SmtpClient SmtpServer = new SmtpClient(vipSetMailHostInfo.SmtpServer);
SmtpServer.Credentials = new NetworkCredential(vipSetMailHostInfo.SmtpUser, vipSetMailHostInfo.SmtpPasswor);
SmtpServer.Port = 25;
SmtpServer.EnableSsl = false;
// Send the mail message
SmtpServer.Send(mMailMessage);
re = true;
}
catch (Exception ex)
{
ex.Message.ToString();
re = false; }
return re;
}
Csharp: Send Email的更多相关文章
- Try to write a script to send e-mail but failed
#-*-coding: utf-8 -*- '''使用Python去发送邮件但是不成功,运行后,等待一段时间, 返回[Errno 10060] A connection attempt failed ...
- python auto send email
/*************************************************************************** * python auto send emai ...
- Check SMTP Server Availability for ORA-29278 or ORA-29279 errors using UTL_SMTP to Send Email
Check SMTP Server Availability for ORA-29278 or ORA-29279 errors using UTL_SMTP to Send Email. (文档 I ...
- Send Email in Robot Framework Python Using Gmail
转载自:http://seleniummaster.com/sitecontent/index.php/selenium-robot-framework-menu/selenium-robot-fra ...
- 5 Ways to Send Email From Linux Command Line
https://tecadmin.net/ways-to-send-email-from-linux-command-line/ We all know the importance of email ...
- [476] Database Mail is not enabled for agent notifications. Cannot send e-mail to
配置完DB Mail后JOB的的通知邮件不能发送,日志报错476] Database Mail is not enabled for agent notifications. Cannot send ...
- Send email alert from Performance Monitor using PowerShell script (检测windows服务器的cpu 硬盘 服务等性能,发email的方法) -摘自网络
I have created an alert in Performance Monitor (Windows Server 2008 R2) that should be triggered whe ...
- Send Email
private string SendEmail(string mailTo, string body, ref int sendresult) { string errorEmailAddress ...
- .Net Core Send Email
1.安装Nuget包MailKit,引用命名空间. using MailKit.Net.Smtp; using MimeKit; 注意:引用MailKit对应最新版本 2.定义收发地址和标题 Mime ...
随机推荐
- query flot 直方图上显示对应的y值
方法1:使用在图上加 相对定位的 div 提示对应的直方图数量. 具体实现:获取直方图上所有的点,得到y值和对应的坐标位置,插入相对div 主要js代码:plot 为对应的图对象 //初始化柱状图数据 ...
- 【python】10分钟教你用python下载和拼接微信好友头像图片
前言 相信微信大家是用得再多也不过了.那么,对于python+微信,又能玩出什么新的花样呢?下面小编就给大家带来一个好玩的东西.用python下载所有的微信好友的头像,然后拼接成一张大图.这样,大家就 ...
- python学习之路---day12
生成器和生成器表达式一:生成器 生成器实质上就是迭代器. 三种方式获取生成器: 01:通过生成器函数 02:通过各种推导式实现生成器 03:通过数据的转换也可以获取生成器 eg:普通函数 def fu ...
- Android newsClient 小实例应用
1.newsClient新闻客户端涉及知识点汇总: (1)ListView(用来显示消息) (2)开子线程去服务器取数据 (3)解析xml文件 (4)利用handler或者runOnUiThread( ...
- C++_函数2-内联函数
内联函数的目的是为了提高程序运行速度所做的一项改进. 常规函数与内联函数的区别不在于编写方式,而在于C++编译器如何将它们组合到程序中. 编译过程的最终产品是:可执行程序,由一组机器语言指令组成.运行 ...
- codeforces 1068d Array Without Local Maximums dp
题目传送门 题目大意:给出一个长度为n的数组,这个数组有的数是给出的,有的数是固定的,且范围都在[1,200]之间,要求这个数组中,每一个数字都小于等于 前后两个数字的最大值,求方案数mod p. 思 ...
- Advanced Data Structures in competitive programming
1.bit #define isOn(S, j) (S & (1 << j)) #define setBit(S, j) (S |= (1 << j)) #define ...
- 小a与“204”------数列、排序
链接:https://ac.nowcoder.com/acm/contest/317/B来源:牛客网 小a非常喜欢204204这个数字,因为′a′+′k′=204′a′+′k′=204. 现在他有一个 ...
- dcoker machine
Docker Machine是一个安装和管理 Docker 的工具, 它有自己的命令行工具:docker-machine.Docker Machine简化了Docker的安装和远程管理, 不仅可以管理 ...
- (转)关于INF为0x3f3f3f3f
转自https://blog.csdn.net/jiange_zh/article/details/50198097 在算法竞赛中,我们常常需要用到一个“无穷大”的值,对于我来说,大多数时间我会根据具 ...