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 {}
}
}
[邮件]发送多人MAIL类
最新推荐文章于 2025-09-12 14:21:37 发布
