[邮件]发送多人MAIL类

using System; using System.Data; using System.Configuration; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.Net; using System.Net.Mail; using System.Text; using System.Collections.Generic; using System.Text.RegularExpressions; /// <summary> /// NetMail 的摘要说明 /// </summary> public class NetMail { public NetMail() { } public static void mailadd(string mailto, string mailsubject, string mailbody, string attech)//创建Mail,填入发送人,主题,內容 { // try //HTML示例如下 //<html><head><title></title></head><body style='font-size: 10pt'>david_520042 //<br /> 您好,这是系统自动发送给您的邮件,无需回复。 //<br />MRP程式运行前物料档案检查已经跑完,请<a href='http://172.168.0.45/shatinfo/Login.aspx'>进入</a> //<br />系统管理员 2008/12/12<br /></body></html> { MailMessage mlMsg = new MailMessage(); //处理多个收件人 string[] toArray = mailto.Split(','); foreach (string i in toArray) { mlMsg.To.Add(new MailAddress(i)); } mlMsg.Subject = mailsubject; mlMsg.Body = mailbody; mlMsg.IsBodyHtml = true; mlMsg.From = new MailAddress("workflowweb@shinhint.gd.cn","Automatic(自动化)"); //附件 if (attech != "") { string[] attArray = attech.Split(','); foreach (string a in attArray) { string strFilePath = @a; Attachment attachment1 = new Attachment(strFilePath); attachment1.Name = System.IO.Path.GetFileName(strFilePath); //attachment1.NameEncoding = Encoding.UTF8; attachment1.TransferEncoding = System.Net.Mime.TransferEncoding.Base64; 内嵌式附件 //attachment1.ContentDisposition.Inline = true; //attachment1.ContentDisposition.DispositionType = // System.Net.Mime.DispositionTypeNames.Inline; //attachment1. mlMsg.Attachments.Add(attachment1); } } SmtpClient smtpClient = new SmtpClient("mailshinhint.shinhint"); smtpClient.Credentials = new NetworkCredential("workflowweb", "1234"); //smtpClient.Timeout = 1000; smtpClient.EnableSsl =false; smtpClient.Send(mlMsg); } // catch {} } }


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值