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 ...
随机推荐
- Spring Eureka的使用入门
Eureka调度服务: Gradle依赖包: 基础框架依赖配置核心代码: buildscript { repositories { mavenCentral() } dependencies {cla ...
- 扩增子分析QIIME2. 1简介和安装
原网站:https://blog.csdn.net/woodcorpse/article/details/75103929 声明:本文为QIIME2官方帮助文档的中文版,由中科院遗传发育所刘永鑫博士翻 ...
- 洛谷 P3275 [SCOI2011]糖果
题目链接 题解 差分约束 学过的应该都会做 不会的自行百度,这里不多讲 opt=1 连一条长度为0的双向边 opt=2 (u->v) \(len=-1\) opt=3 (v->u) \(l ...
- hdu6183 Color it 线段树动态开点+查询减枝
题目传送门 题目大意: 有多次操作.操作0是清空二维平面的点,操作1是往二维平面(x,y)上放一个颜色为c的点,操作2是查询一个贴着y轴的矩形内有几种颜色的点,操作3退出程序. 思路: 由于查询的矩形 ...
- BZOJ - 1458 / P4311 最大流应用 贪心
题意:给定n*m的图,每个士兵可以占领当前行和列,第i行至少要R[i]个士兵占领,第j列至少要C[j]个士兵占领,部分网格无法占领,求占领所用最少士兵数,若无解则输出orz 士兵的贡献情况有1(只有效 ...
- 04-树5 Root of AVL Tree (25 分)
An AVL tree is a self-balancing binary search tree. In an AVL tree, the heights of the two child sub ...
- PIE SDK地图放大镜
放大镜,在地图的浏览过程中在主地图和次地图中起到很好的辅助作用, 要实现放大镜功能主要就是通过两个mapControl控件,主地图控件是mapControlMain,放大镜控件是UserControl ...
- docker jenkins安装(一)
https://hub.docker.com/r/jenkins/jenkins jenkins的docker官方镜像地址 https://jenkins.io/ jenkins官方网站 环境: ...
- jquery 去除字符串左右空格
/*** 删除左右两端的空格*/String.prototype.trim=function(){return this.replace(/(^\s*)|(\s*$)/g, '');} 调用方式: v ...
- Python学习 day06
一.== 和 is == 比较的是值 is 比较的是地址 id() -- 返回对象的内存地址 例: 赋值操作是将地址赋给变量 Python 中会实现创建一个小型的整形池,范围为 [-5,25 ...