/// <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的更多相关文章

  1. Try to write a script to send e-mail but failed

    #-*-coding: utf-8 -*- '''使用Python去发送邮件但是不成功,运行后,等待一段时间, 返回[Errno 10060] A connection attempt failed ...

  2. python auto send email

    /*************************************************************************** * python auto send emai ...

  3. 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 ...

  4. Send Email in Robot Framework Python Using Gmail

    转载自:http://seleniummaster.com/sitecontent/index.php/selenium-robot-framework-menu/selenium-robot-fra ...

  5. 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 ...

  6. [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 ...

  7. 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 ...

  8. Send Email

    private string SendEmail(string mailTo, string body, ref int sendresult) { string errorEmailAddress ...

  9. .Net Core Send Email

    1.安装Nuget包MailKit,引用命名空间. using MailKit.Net.Smtp; using MimeKit; 注意:引用MailKit对应最新版本 2.定义收发地址和标题 Mime ...

随机推荐

  1. [Swift实际操作]九、完整实例-(2)在Xcode 10中创建新项目

    本文将在Xcode中创建上一文<在iTunesConnect网站中创建产品>在iTunes Connect创建的产品具有相同的Bundle ID的应用程序. 在项目模板窗口中,选择单视图模 ...

  2. 静态库(.a)与动态库(.so)的简明介绍

    静态库(.a)与动态库(.so)的简明介绍 gcc有很多关于静态库,动态库的选项如-l,-L,-fPIC,-shared -Wl,-soname,看着很复杂容易混淆,其实静态库和动态库都是应需而生,只 ...

  3. windows下Idea结合maven开发spark和本地调试

    本人的开发环境: 1.虚拟机centos 6.5 2.jdk 1.8 3.spark2.2.0 4.scala 2.11.8 5.maven 3.5.2     在开发和搭环境时必须注意版本兼容的问题 ...

  4. Opencv博文收藏列表

    opencv识别二维码:https://blog.csdn.net/jia20003/article/details/77348170 opencv视频:http://www.opencv.org.c ...

  5. [USACO07DEC]泥水坑Mud Puddles BFS BZOJ 1627

    题目描述 Farmer John is leaving his house promptly at 6 AM for his daily milking of Bessie. However, the ...

  6. 【算法笔记】B1004 成绩排名

    1004 成绩排名 (20 分) 读入 n(>0)名学生的姓名.学号.成绩,分别输出成绩最高和成绩最低学生的姓名和学号. 输入格式: 每个测试输入包含 1 个测试用例,格式为 第 1 行:正整数 ...

  7. 洛谷 P4568 [JLOI2011]飞行路线

    题目描述 Alice和Bob现在要乘飞机旅行,他们选择了一家相对便宜的航空公司.该航空公司一共在n个城市设有业务,设这些城市分别标记为0到n-1,一共有m种航线,每种航线连接两个城市,并且航线有一定的 ...

  8. 尺取法 javascript算法

    给定长度为n的数列整数a0,a1……an-1 以及整数S.求出总和不小于S的连续子序列的长度的最小值.如果解不存在,则输出0. 输入 n=10 S=15 a=[5,1,3,5,10,7,4,9,2,8 ...

  9. Spring 和整个体系 @Value注解 配合属性文件.property

    未来学习方向   重要思路 学的时候看官方文档,系统地学,比如学Spring Boot ,但真正使用的时候,有比自动化(条件化)配置,约定即配置 更好的方法(这个可读性不强,对电脑来说它执行的代码一样 ...

  10. 安卓获取输入法高度与ViewTreeObserver讲解

    目录 安卓获取输入法高度 前言 清单 开始 ViewTreeObserver讲解 获取输入法高度原理 思路 实现 关于ViewTreeObserver 定义 继承 摘要 获取View高度的三种方法 源 ...