SMTP email from C#
/// <summary>
/// 一人一附件发送邮件
/// 2017-05-17 涂聚文 GeovinDu
/// </summary>
/// <param name="To">接收邮件人</param>
/// <param name="Subject">邮件标题</param>
/// <param name="Msg">邮件内容</param>
/// <param name="bodyHtml">是否網頁</param>
/// <param name="AttachmentStream"></param>
/// <param name="AttachmentFileName">附件</param>
/// <returns></returns>
public static bool SendEmaildu(string To, string Subject, string Msg, bool bodyHtml, MemoryStream AttachmentStream,string AttachmentFileName)
{
bool SendOk = false;
try
{
System.Net.Mail.MailMessage newMsg = new System.Net.Mail.MailMessage(System.Configuration.ConfigurationManager.AppSettings["mailCfg"], To, Subject, Msg);
newMsg.BodyEncoding = System.Text.Encoding.UTF8;
newMsg.HeadersEncoding = System.Text.Encoding.UTF8;
newMsg.SubjectEncoding = System.Text.Encoding.UTF8; System.Net.Mail.SmtpClient smtpClient = new System.Net.Mail.SmtpClient();
//smtpClient.Credentials = new NetworkCredential("geovindu@dusystem.com","888888");
//smtpClient.Port = 25;
//smtpClient.EnableSsl = false;
if (AttachmentStream != null && AttachmentFileName != null)
{ // ADD AN ATTACHMENT.
//String sFile = @"C:\Source\LNS_IS.TXT";
//MailAttachment oAttch = new MailAttachment(sFile, MailEncoding.Base64);
//string filePath = @"C:\TestEmail\SKYPE11月黑咭生日會員.xls";
//MemoryStream memStream = new MemoryStream();
//using (FileStream fileStream = File.OpenRead(filePath))
//{ // memStream.SetLength(fileStream.Length);
// fileStream.Read(memStream.GetBuffer(), 0, (int)fileStream.Length);
//} newMsg.Attachments.Add(new Attachment(AttachmentStream, AttachmentFileName)); //MediaTypeNames.Image.Jpeg) //System.Net.Mail.Attachment attachment = new System.Net.Mail.Attachment(AttachmentStream, AttachmentFileName);
//System.Net.Mime.ContentDisposition disposition = attachment.ContentDisposition;
//disposition.FileName = AttachmentFileName;
//disposition.DispositionType = System.Net.Mime.DispositionTypeNames.Attachment;
//newMsg.Attachments.Add(attachment); }
newMsg.IsBodyHtml = bodyHtml; smtpClient.Send(newMsg);
SendOk = true;
//return SENT_OK;
}
catch (Exception ex)
{
ex.Message.ToString();
AttachmentStream.Close();
SendOk = false;
//"Error: " + ex.Message + "<br/><br/>Inner Exception: "+ ex.InnerException; }
AttachmentStream.Close();
return SendOk; }
/// <summary>
/// 一人一附件发送邮件
/// 2017-05-17 涂聚文 GeovinDu
/// </summary>
/// <param name="To">接收邮件人</param>
/// <param name="Subject">邮件标题</param>
/// <param name="Msg">邮件内容</param>
/// <param name="bodyHtml">是否網頁</param>
/// <param name="AttachmentFileName">附件</param>
/// <returns></returns>
public static bool SendEmaildu(string To, string Subject, string Msg, bool bodyHtml, string AttachmentFileName)
{
MemoryStream AttachmentStream = new MemoryStream();
bool SendOk = false;
try
{
System.Net.Mail.MailMessage newMsg = new System.Net.Mail.MailMessage(System.Configuration.ConfigurationManager.AppSettings["mailCfg"], To, Subject, Msg);
newMsg.BodyEncoding = System.Text.Encoding.UTF8;
newMsg.HeadersEncoding = System.Text.Encoding.UTF8;
newMsg.SubjectEncoding = System.Text.Encoding.UTF8; System.Net.Mail.SmtpClient smtpClient = new System.Net.Mail.SmtpClient();
//smtpClient.Credentials = new NetworkCredential("geovindu@dusystem.com","888888");
//smtpClient.Port = 25;
//smtpClient.EnableSsl = false;
if (AttachmentStream != null && AttachmentFileName != null)
{ // ADD AN ATTACHMENT.
//String sFile = @"C:\Source\LNS_IS.TXT";
//MailAttachment oAttch = new MailAttachment(sFile, MailEncoding.Base64);
//string filePath = @"C:\TestEmail\SKYPE11月黑咭生日會員.xls";
//MemoryStream memStream = new MemoryStream();
//using (FileStream fileStream = File.OpenRead(filePath))
//{ // memStream.SetLength(fileStream.Length);
// fileStream.Read(memStream.GetBuffer(), 0, (int)fileStream.Length);
//} newMsg.Attachments.Add(new Attachment(AttachmentStream, AttachmentFileName)); //MediaTypeNames.Image.Jpeg) //System.Net.Mail.Attachment attachment = new System.Net.Mail.Attachment(AttachmentStream, AttachmentFileName);
//System.Net.Mime.ContentDisposition disposition = attachment.ContentDisposition;
//disposition.FileName = AttachmentFileName;
//disposition.DispositionType = System.Net.Mime.DispositionTypeNames.Attachment;
//newMsg.Attachments.Add(attachment); }
newMsg.IsBodyHtml = bodyHtml;
smtpClient.Send(newMsg);
SendOk = true;
//return SENT_OK;
}
catch (Exception ex)
{
ex.Message.ToString();
AttachmentStream.Close();
SendOk = false;
//"Error: " + ex.Message + "<br/><br/>Inner Exception: "+ ex.InnerException; }
AttachmentStream.Close();
return SendOk; } /// <summary>
/// 一人多附件发送邮件
/// 2019-06-18 涂聚文 GeovinDu
/// </summary>
/// <param name="To">接收邮件人</param>
/// <param name="Subject">邮件标题</param>
/// <param name="Msg">邮件内容</param>
/// <param name="bodyHtml">是否網頁</param>
/// <param name="AttachmentFiles">多附件</param>
/// <returns></returns>
public static bool SendEmailduFiles(string To, string Subject, string Msg, bool bodyHtml, List<string> AttachmentFiles)
{
MemoryStream AttachmentStream = new MemoryStream();
bool SendOk = false;
try
{
System.Net.Mail.MailMessage newMsg = new System.Net.Mail.MailMessage(System.Configuration.ConfigurationManager.AppSettings["mailCfg"], To, Subject, Msg);
newMsg.BodyEncoding = System.Text.Encoding.UTF8;
newMsg.HeadersEncoding = System.Text.Encoding.UTF8;
newMsg.SubjectEncoding = System.Text.Encoding.UTF8; System.Net.Mail.SmtpClient smtpClient = new System.Net.Mail.SmtpClient();
//smtpClient.Credentials = new NetworkCredential("geovindu@dusystem.com","888888");
//smtpClient.Port = 25;
//smtpClient.EnableSsl = false; if (AttachmentStream != null && AttachmentFiles != null)
{ foreach (string filename in AttachmentFiles)
{
newMsg.Attachments.Add(new Attachment(AttachmentStream, filename)); //MediaTypeNames.Image.Jpeg) } }
newMsg.IsBodyHtml = bodyHtml;
smtpClient.Send(newMsg);
SendOk = true;
}
catch (Exception ex)
{
ex.Message.ToString();
AttachmentStream.Close();
SendOk = false;
}
AttachmentStream.Close();
return SendOk;
} /// <summary>
/// 多人多附件发送邮件
/// 不考虑统计每封邮件发送状态(另外考虑完善代码)
/// 2019-06-18 涂聚文 GeovinDu
/// </summary>
/// <param name="Tos">多人接收邮件人</param>
/// <param name="Subject">邮件标题</param>
/// <param name="Msg">邮件内容</param>
/// <param name="bodyHtml">是否網頁</param>
/// <param name="AttachmentFiles">多附件</param>
/// <returns></returns>
public static bool SendEmailsAndFiles(List<string> Tos, string Subject, string Msg, bool bodyHtml, List<string> AttachmentFiles)
{
MemoryStream AttachmentStream = new MemoryStream();
bool SendOk = false;
List<Attachment> all = new List<Attachment>();
try
{
if (AttachmentStream != null && AttachmentFiles != null)
{
foreach (string filename in AttachmentFiles)
{ all.Add(new Attachment(AttachmentStream, filename));
}
}
if (Tos.Count > 0)
{ foreach (string To in Tos)
{
System.Net.Mail.MailMessage newMsg = new System.Net.Mail.MailMessage(System.Configuration.ConfigurationManager.AppSettings["mailCfg"], To, Subject, Msg);
newMsg.BodyEncoding = System.Text.Encoding.UTF8;
newMsg.HeadersEncoding = System.Text.Encoding.UTF8;
newMsg.SubjectEncoding = System.Text.Encoding.UTF8;
System.Net.Mail.SmtpClient smtpClient = new System.Net.Mail.SmtpClient();
//smtpClient.Credentials = new NetworkCredential("geovindu@dusystem.com","888888");
//smtpClient.Port = 25;
//smtpClient.EnableSsl = false;
if (AttachmentStream != null && AttachmentFiles != null)
{
foreach (Attachment attname in all)
{
newMsg.Attachments.Add(attname); //MediaTypeNames.Image.Jpeg) }
}
newMsg.IsBodyHtml = bodyHtml;
smtpClient.Send(newMsg);
SendOk = true;
}
}
}
catch (Exception ex)
{
ex.Message.ToString();
AttachmentStream.Close();
SendOk = false;
}
AttachmentStream.Close();
return SendOk;
}
测试代码:
MemoryStream theMemStream = new MemoryStream();
string file = @"C:\TestEmail\SKYPE11月黑咭生日會員.xls"; //C:\TestEmail\Top1000WorldBanks2014.pdf
if (File.Exists(file))
{
//AttachmentStream = File.Open(file, FileMode.Open, FileAccess.Read); byte[] filebyte = MirosoftSmptHelper.ReadFile(file); theMemStream.Write(filebyte, 0, filebyte.Length);// = File.OpenRead(file);
theMemStream.Position = 0; //theMemStream.Close(); // AttachmentStream = theMemStream;// BytesToStream(filebyte); //new MemoryStream(filebyte);// // BytesToStream(filebyte);// FileToStream(file);// //AttachmentStream.CanTimeout =true;
//AttachmentStream.ReadTimeout = 1000;
//AttachmentStream.WriteTimeout = 1000;
//AttachmentStream = BytesToStream(filebyte); //theMemStream.Close();
}
List<string> AttachmentFiles = new List<string>();
AttachmentFiles.Add("馬拉松獎牌刻字.xlsx");
AttachmentFiles.Add("进一步优化供给推动消费平稳增长2019.pdf");
AttachmentFiles.Add("逃犯条例草案.pdf");
AttachmentFiles.Add("复习卷14.doc");
List<string> Tos = new List<string>();
Tos.Add("geovindu@163.com");
Tos.Add("geovindu@hotmail.com");
Tos.Add("geovi@qq.com"); //1.一人一附件
//bool issend = MirosoftSmptHelper.SendEmaildu("geovindu@163.com", "中文文件名.net 4.0,geovindu 涂聚文塗聚文工團、", "<p> 生命運浪漫滿屋geovindu江蘇黃河</p><br/><p>上官放個屁,下官一台戲</p>", true,"馬拉松獎牌刻字.xlsx");
//2.一人多附件
//bool issend = MirosoftSmptHelper.SendEmailduFiles("geovindu@163.com", "中文文件名.net 4.0,geovindu 涂聚文塗聚文工團、", "<p> 生命運浪漫滿屋geovindu江蘇黃河</p><br/><p>上官放個屁,下官一台戲</p>", true, AttachmentFiles);
//3.多人多附件
bool issend = MirosoftSmptHelper.SendEmailsAndFiles(Tos, "中文文件名.net 4.0,geovindu 涂聚文塗聚文工團、", "<p> 生命運浪漫滿屋geovindu江蘇黃河</p><br/><p>上官放個屁,下官一台戲</p>", true, AttachmentFiles);
theMemStream.Close();
if (issend)
{
MessageBox.Show("ok");
}
else
{
MessageBox.Show("no");
}
}
不忘初心,方得始终;初心易得,始终难守。
/// <summary>
/// 多人多附件发送邮件
/// 不考虑统计每封邮件发送状态(另外考虑完善代码)
/// 2019-06-18 涂聚文 GeovinDu
/// 2019-07-01
/// </summary>
/// <param name="Tos">多人接收邮件人</param>
/// <param name="Subject">邮件标题</param>
/// <param name="Msg">邮件内容</param>
/// <param name="bodyHtml">是否網頁</param>
/// <param name="AttachmentFiles">多附件--具体文件地址</param>
/// <returns></returns>
public static bool SendEmailsAndFiles(List<string> Tos, string Subject, string Msg, bool bodyHtml, List<string> AttachmentFiles)
{
MemoryStream AttachmentStream = new MemoryStream();
bool SendOk = false;
List<Attachment> all = new List<Attachment>();
try
{
if (AttachmentStream != null && AttachmentFiles != null)
{
foreach (string filename in AttachmentFiles)
{
Attachment attachment = new Attachment(filename, MediaTypeNames.Application.Octet); // //AttachmentStream, filename
ContentDisposition disposition = attachment.ContentDisposition;
disposition.CreationDate = File.GetCreationTime(filename);
disposition.ModificationDate = File.GetLastWriteTime(filename);
disposition.ReadDate = File.GetLastAccessTime(filename);
disposition.FileName = Path.GetFileName(filename);
disposition.Size = new FileInfo(filename).Length;
disposition.DispositionType = DispositionTypeNames.Attachment;
all.Add(attachment); //new Attachment(AttachmentStream, filename)
}
}
if (Tos.Count > 0)
{ foreach (string To in Tos)
{
System.Net.Mail.MailMessage newMsg = new System.Net.Mail.MailMessage(System.Configuration.ConfigurationManager.AppSettings["mailCfg"], To, Subject, Msg);
newMsg.BodyEncoding = System.Text.Encoding.UTF8;
newMsg.HeadersEncoding = System.Text.Encoding.UTF8;
newMsg.SubjectEncoding = System.Text.Encoding.UTF8;
System.Net.Mail.SmtpClient smtpClient = new System.Net.Mail.SmtpClient();
//smtpClient.Credentials = new NetworkCredential("geovindu@dusystem.com","888888");
//smtpClient.Port = 25;
//smtpClient.EnableSsl = false;
if (AttachmentStream != null && AttachmentFiles != null)
{
foreach (Attachment attname in all)
{ newMsg.Attachments.Add(attname); //MediaTypeNames.Image.Jpeg) }
}
newMsg.IsBodyHtml = bodyHtml;
smtpClient.Send(newMsg);
SendOk = true;
}
}
}
catch (Exception ex)
{
ex.Message.ToString();
AttachmentStream.Close();
SendOk = false;
}
AttachmentStream.Close();
return SendOk;
} /// <summary>
/// 多人多附件发送邮件
/// 不考虑统计每封邮件发送状态(另外考虑完善代码)
/// 2019-07-01 涂聚文 GeovinDu
/// </summary>
/// <param name="Tos">多人接收邮件人</param>
/// <param name="Subject">邮件标题</param>
/// <param name="Msg">邮件内容</param>
/// <param name="bodyHtml">是否網頁</param>
/// <param name="AttachmentFiles">多附件--根据运行程序目录地址</param>
/// <returns></returns>
public static bool SendEmailsAndLocalFiles(List<string> Tos, string Subject, string Msg, bool bodyHtml, List<string> AttachmentFiles)
{
MemoryStream AttachmentStream = new MemoryStream();
bool SendOk = false;
List<Attachment> all = new List<Attachment>();
try
{
if (AttachmentStream != null && AttachmentFiles != null)
{
foreach (string filename in AttachmentFiles)
{
//具体的文件地址,用此法
//Attachment attachment = new Attachment(filename, MediaTypeNames.Application.Octet); // //AttachmentStream, filename
//ContentDisposition disposition = attachment.ContentDisposition;
//disposition.CreationDate = File.GetCreationTime(filename);
//disposition.ModificationDate = File.GetLastWriteTime(filename);
//disposition.ReadDate = File.GetLastAccessTime(filename);
//disposition.FileName = Path.GetFileName(filename);
//disposition.Size = new FileInfo(filename).Length;
//disposition.DispositionType = DispositionTypeNames.Attachment;
all.Add(new Attachment(AttachmentStream, filename));//在运行程序的目录的文件没有问题,可执行。如是不是此语言件地址,附件无效
}
}
if (Tos.Count > 0)
{ foreach (string To in Tos)
{
System.Net.Mail.MailMessage newMsg = new System.Net.Mail.MailMessage(System.Configuration.ConfigurationManager.AppSettings["mailCfg"], To, Subject, Msg);
newMsg.BodyEncoding = System.Text.Encoding.UTF8;
newMsg.HeadersEncoding = System.Text.Encoding.UTF8;
newMsg.SubjectEncoding = System.Text.Encoding.UTF8;
System.Net.Mail.SmtpClient smtpClient = new System.Net.Mail.SmtpClient();
//smtpClient.Credentials = new NetworkCredential("geovindu@dusystem.com","888888");
//smtpClient.Port = 25;
//smtpClient.EnableSsl = false;
if (AttachmentStream != null && AttachmentFiles != null)
{
foreach (Attachment attname in all)
{
newMsg.Attachments.Add(attname); //MediaTypeNames.Image.Jpeg) }
}
newMsg.IsBodyHtml = bodyHtml;
smtpClient.Send(newMsg);
SendOk = true;
}
}
}
catch (Exception ex)
{
ex.Message.ToString();
AttachmentStream.Close();
SendOk = false;
}
AttachmentStream.Close();
return SendOk;
}
/// <summary>
/// 20190702 多人邮件
/// geovindu 涂聚文
/// </summary>
/// <param name="Mails"></param>
/// <param name="Subject"></param>
/// <param name="Msg"></param>
/// <param name="bodyHtml"></param>
/// <param name="AttachmentFiles"></param>
/// <returns></returns>
public static bool SendEmailsFiles(List<MailAddress> Mails, string Subject, string Msg, bool bodyHtml, List<string> AttachmentFiles)
{
MemoryStream AttachmentStream = new MemoryStream();
bool SendOk = false;
List<Attachment> all = new List<Attachment>();
try
{
if (AttachmentStream != null && AttachmentFiles != null)
{
foreach (string filename in AttachmentFiles)
{
//具体的文件地址,用此法
Attachment attachment = new Attachment(filename, MediaTypeNames.Application.Octet); // //AttachmentStream, filename
ContentDisposition disposition = attachment.ContentDisposition;
disposition.CreationDate = File.GetCreationTime(filename);
disposition.ModificationDate = File.GetLastWriteTime(filename);
disposition.ReadDate = File.GetLastAccessTime(filename);
disposition.FileName = Path.GetFileName(filename);
disposition.Size = new FileInfo(filename).Length;
disposition.DispositionType = DispositionTypeNames.Attachment;
all.Add(attachment);//在运行程序的目录的文件没有问题,可执行。如是不是此语言件地址,附件无效
}
}
if (Mails.Count > 0)
{ int c = 1;
foreach (MailAddress ToAddress in Mails)
{ MailAddress from=new MailAddress(System.Configuration.ConfigurationManager.AppSettings["mailCfg"],System.Configuration.ConfigurationManager.AppSettings["displayName"]);
//from.DisplayName="";
// from.Address=;
System.Net.Mail.MailMessage newMsg = new System.Net.Mail.MailMessage();
newMsg.From = from;
newMsg.To.Add(ToAddress);
newMsg.Subject = Subject;
newMsg.Body = Msg;
newMsg.BodyEncoding = System.Text.Encoding.UTF8;
newMsg.HeadersEncoding = System.Text.Encoding.UTF8;
newMsg.SubjectEncoding = System.Text.Encoding.UTF8;
System.Net.Mail.SmtpClient smtpClient = new System.Net.Mail.SmtpClient();
//smtpClient.Credentials = new NetworkCredential("geovindu@dusystem.com","888888");
//smtpClient.Port = 25;
//smtpClient.EnableSsl = false;
if (AttachmentStream != null && AttachmentFiles != null)
{
foreach (Attachment attname in all)
{
newMsg.Attachments.Add(attname); //MediaTypeNames.Image.Jpeg)
}
}
newMsg.IsBodyHtml = bodyHtml;
//smtpClient.Send(newMsg);
smtpClient.SendCompleted += new SendCompletedEventHandler(SendCompletedCallback);
string userState = "test message:"+c.ToString();
smtpClient.SendAsync(newMsg, userState);
SendOk = true;
c++;
} }
}
catch (Exception ex)
{
ex.Message.ToString();
AttachmentStream.Close();
SendOk = false;
}
AttachmentStream.Close();
return SendOk;
}
/// <summary>
/// 一人多附件
/// </summary>
/// <param name="Mails"></param>
/// <param name="Subject"></param>
/// <param name="Msg"></param>
/// <param name="bodyHtml"></param>
/// <param name="AttachmentFiles"></param>
/// <returns></returns>
public static bool SendEmailFiles(MailAddress Mails, string Subject, string Msg, bool bodyHtml, List<string> AttachmentFiles)
{
MemoryStream AttachmentStream = new MemoryStream();
bool SendOk = false;
List<Attachment> all = new List<Attachment>();
try
{
if (AttachmentStream != null && AttachmentFiles != null)
{
foreach (string filename in AttachmentFiles)
{
//具体的文件地址,用此法
Attachment attachment = new Attachment(filename, MediaTypeNames.Application.Octet); // //AttachmentStream, filename
ContentDisposition disposition = attachment.ContentDisposition;
disposition.CreationDate = File.GetCreationTime(filename);
disposition.ModificationDate = File.GetLastWriteTime(filename);
disposition.ReadDate = File.GetLastAccessTime(filename);
disposition.FileName = Path.GetFileName(filename);
disposition.Size = new FileInfo(filename).Length;
disposition.DispositionType = DispositionTypeNames.Attachment;
all.Add(attachment);//在运行程序的目录的文件没有问题,可执行。如是不是此语言件地址,附件无效
}
} MailAddress from = new MailAddress(System.Configuration.ConfigurationManager.AppSettings["mailCfg"], System.Configuration.ConfigurationManager.AppSettings["displayName"]);
//from.DisplayName="";
// from.Address=;
System.Net.Mail.MailMessage newMsg = new System.Net.Mail.MailMessage();
newMsg.From = from;
newMsg.To.Add(Mails);
newMsg.Subject = Subject;
newMsg.Body = Msg;
newMsg.BodyEncoding = System.Text.Encoding.UTF8;
newMsg.HeadersEncoding = System.Text.Encoding.UTF8;
newMsg.SubjectEncoding = System.Text.Encoding.UTF8;
System.Net.Mail.SmtpClient smtpClient = new System.Net.Mail.SmtpClient();
//smtpClient.Credentials = new NetworkCredential("geovindu@dusystem.com","888888");
//smtpClient.Port = 25;
//smtpClient.EnableSsl = false;
if (AttachmentStream != null && AttachmentFiles != null)
{
foreach (Attachment attname in all)
{
newMsg.Attachments.Add(attname); //MediaTypeNames.Image.Jpeg)
}
}
newMsg.IsBodyHtml = bodyHtml;
//smtpClient.Send(newMsg);
smtpClient.SendCompleted += new SendCompletedEventHandler(SendCompletedCallback);
string userState = "test message:发送中";
smtpClient.SendAsync(newMsg, userState);
SendOk = true; }
catch (Exception ex)
{
ex.Message.ToString();
AttachmentStream.Close();
SendOk = false;
}
AttachmentStream.Close();
return SendOk;
}
测试
List<MailAddress> mails = new List<MailAddress>();
MailAddress address = null;
address = new MailAddress("geovindu@163.com", "涂聚文", Encoding.UTF8);
mails.Add(address);
address = new MailAddress("geovindu@hotmail.com", "塗聚文", Encoding.UTF8);
mails.Add(address);
address = new MailAddress("463588883@qq.com", "捷為工作室", Encoding.UTF8);
mails.Add(address);
string strMessage = string.Empty;
string subject = string.Empty; subject=txtSubject.Text.Trim();
strMessage = htmlEditUserControl1.HtmlEditControl.DocumentText; //1.一人一附件
//bool issend = MirosoftSmptHelper.SendEmaildu("geovindu@163.com", "中文文件名.net 4.0,geovindu 涂聚文塗聚文工團、", "<p> 生命運浪漫滿屋geovindu江蘇黃河</p><br/><p>上官放個屁,下官一台戲</p>", true,"馬拉松獎牌刻字.xlsx");
//2.一人多附件
//bool issend = MirosoftSmptHelper.SendEmailduFiles("geovindu@163.com", "中文文件名.net 4.0,geovindu 涂聚文塗聚文工團、", "<p> 生命運浪漫滿屋geovindu江蘇黃河</p><br/><p>上官放個屁,下官一台戲</p>", true, AttachmentFiles);
//3.多人多附件
//bool issend = MirosoftSmptHelper.SendEmailsAndFiles(Tos, subject, strMessage, true, AttachmentFiles);
bool issend = MirosoftSmptHelper.SendEmailsFiles(mails, subject, strMessage, true, AttachmentFiles);
SMTP email from C#的更多相关文章
- gerrit 调试smtp email
- 使用Python调用SMTP服务自动发送Email
需求背景 假设我们想设计一个定时任务,比如每天定时的用python来测试服务是否在正常运行,但是又不希望每天登录到系统后台去查看服务状态.这里我们就可以采取python的smtp模块进行任务结果广播, ...
- maven小项目注册服务(一)--email和persist模块
跟着书里的讲解,跟着做了一遍该项目: 首先明白注册账户的需求: 账号的lD和Email地址都可以用来唯一地标识某个用户,而显示名称则用来显示在页面下,方便浏览.注册的时候用户还需要输入两次密码,以确保 ...
- 配置 SQL Server Email 发送以及 Job 的 Notification通知功能
配置 SQL Server Email 发送以及 Job 的 Notification通知功能 在与数据库相关的项目中, 比如像数据库维护, 性能警报, 程序出错警报或通知都会使用到在 SQL Ser ...
- 自学Zabbix3.10.1.1-事件通知Notifications upon events-媒介类型email
自学Zabbix3.10.1.1-事件通知Notifications upon events-媒介类型email 配置媒介Email Administration→Media types->Cl ...
- SMTP 通过 ssh 通道发送垃圾邮件
通过SSH隧道传输SMTP 根据设计,我们不允许校外机器使用我们的SMTP服务器.如果我们允许它,我们将允许任何和所有使用我们的SMTP服务器来分发垃圾邮件.但是也可以通过我们的SMTP服务器发送邮件 ...
- (44)zabbix报警媒介:email
报警信息将会使用系统自带的sendmail发送,配置比较简单 配置媒介Email Administration→Media types->Click on Create media type ...
- Aras Innovator如何配置SMTP中转Office365
参考文档:http://www.ebdadvisors.com/blog/2015/7/31/configure-an-smtp-server-in-windows-iis-for-aras-inno ...
- Daily Build
Daily Build 是一件非常有意义的事情,也是敏捷开发中关于 “持续集成” 的一个实践.Daily Build 对于开发来说有如下好处: 保证了每次 check in 的代码可用,不会造成整个工 ...
随机推荐
- 为NLog自定义LayoutRenderer
长话短说 前文<解剖HttpClientFactory,自由扩展HttpMessageHandler>主要想讲如何扩展HttpMessageHandler, 示例为在每个Http请求中的 ...
- gulp+webpack+angular1的一点小经验(第二部分webpack包起来的angular1)
又一周过去了,项目也已经做得有点模样了.收集来一些小经验,分享给大家,有疏漏之处,还望指正,海涵. 上周整合了gulp与webpack,那么工具准备差不多了,我们就开始编码吧.编码的框架就是angul ...
- 使用Python编写打字训练小程序
你眼中的程序猿 别人眼中的程序猿,是什么样子?打字如飞,各种炫酷的页面切换,一个个好似黑客般的网站破解.可现实呢? 二指禅的敲键盘,写一行代码,查半天百度-那么如何能让我们从外表上变得更像一个程序猿呢 ...
- 深入比特币原理(三)——交易的输入(input)与输出(output)
本节内容非常重要,如果你不能很好的掌握本节内容,你无法真正理解比特币的运行原理,请务必要学习清楚. 比特币的交易模型为UTXO(unspend transaction output),即只记录未花费的 ...
- 使用react-breadcrumbs-dynamic
这是完全独立于路由器的解决方案,你可以将其与任何版本的React Router(2或3或4)或任何其他用于React的路由库一起使用,或者完全不进行路由.您只需要指定面包屑项目及其道具的组件.然而道具 ...
- python3.6异步IO包asyncio部分核心源码思路梳理
关于python异步编程的演进过程,两篇文章阐述得妥妥当当,明明白白. 中文资料:https://mp.weixin.qq.com/s?__biz=MzIxMjY5NTE0MA==&mid=2 ...
- 阿里巴巴的 Kubernetes 应用管理实践经验与教训
作者 | 孙健波(天元) 阿里巴巴技术专家 导读:本文整理自孙健波在 ArchSummit 大会 2019 北京站演讲稿记录.首先介绍了阿里巴巴基于 Kubernetes 项目进行大规模应用实践过程 ...
- Go语言学习之路
我关于Go语言的博客原本发布于我的个人网站:wwww.liwenzhouu.com.但是被某些人抄怕了,没办法只好搬运到博客园. 我的Go语言学习之路 2015年底我因为工作原因接触到了Go语言,那时 ...
- Java中的try-catch-finally异常处理
Java中的try-catch-finally异常处理 一.异常处理 异常(Exception):是在运行发生的不正常情况. 原始异常处理: if(条件) { 处理办法1 处理办法2 处理办法3 } ...
- Python发送邮件以及对其封装
对Python发送邮件进行封装 Python发送邮件分为四步 连接到smtp服务器 登陆smtp服务器 准备邮件 发送邮件 导入所需要的包 import smtplib from email.mime ...