c#网络应用编程 发送邮件中怎么发送给多人
4个回答
展开全部
用To.Add()方法就可以添加多个收件人了,具体代码:
MailMessage mailObj = new MailMessage();
mailObj.From = new MailAddress("admin" + "@lisco.com.cn");//发信人地址
mailObj.To.Add("LZ" + "6e804" + "@lisco.com.cn");//收信地址
mailObj.To.Add("LZ" + "6e769" + "@lisco.com.cn");//收信地址
mailObj.Subject = mail_text;//邮件标题
//html格式的邮件
mailObj.IsBodyHtml = true;
////设置为高级优先权(可设可不设)
//mailObj.Priority = MailPriority.High;
//使用SmtpMail对象发送邮件
SmtpClient smtp = new SmtpClient("10.128.8.11");
smtp.Send(mailObj);
MailMessage mailObj = new MailMessage();
mailObj.From = new MailAddress("admin" + "@lisco.com.cn");//发信人地址
mailObj.To.Add("LZ" + "6e804" + "@lisco.com.cn");//收信地址
mailObj.To.Add("LZ" + "6e769" + "@lisco.com.cn");//收信地址
mailObj.Subject = mail_text;//邮件标题
//html格式的邮件
mailObj.IsBodyHtml = true;
////设置为高级优先权(可设可不设)
//mailObj.Priority = MailPriority.High;
//使用SmtpMail对象发送邮件
SmtpClient smtp = new SmtpClient("10.128.8.11");
smtp.Send(mailObj);
展开全部
private void SendEMail()
{ string mailFrom = System.Configuration.ConfigurationManager.AppSettings["MailFrom"].ToString();
string mailUser = System.Configuration.ConfigurationManager.AppSettings["MailUser"].ToString();
string mailPassword = System.Configuration.ConfigurationManager.AppSettings["MailPassword"].ToString();
string hostIP = System.Configuration.ConfigurationManager.AppSettings["MailHost"].ToString();
List<string> mailAddress = new List<string>();
string mailSubjct = "邮件主题";
string mailBody = "邮件内容:";
mailAddress.Add("邮件地址");string strReturn = sendMail(mailSubjct, mailBody, mailFrom, mailAddress, hostIP, mailUser, mailPassword, false);
}
public static string sendMail(string mailSubjct, string mailBody, string mailFrom, List<string> mailAddress, string hostIP, string username, string password, bool ssl)
2 {
3 string str = "";
4 try
5 {
6 MailMessage message = new MailMessage
7 {
8 IsBodyHtml = true,
9 Subject = mailSubjct,
10 Body = mailBody,
11
12 From = new MailAddress(mailFrom)
13 };
14 for (int i = 0; i < mailAddress.Count; i++)
15 {
16 message.To.Add(mailAddress[i]);
17 }
18 SmtpClient client = new SmtpClient
19 {
20 EnableSsl = ssl,
21 UseDefaultCredentials = false
22 };
23 NetworkCredential credential = new NetworkCredential(username, password);
24 client.Credentials = credential;
25 client.DeliveryMethod = SmtpDeliveryMethod.Network;
26 client.Host = hostIP;
27 client.Port = 0x19;
28 client.Send(message);
29 }
30 catch (Exception exception)
31 {
32 str = exception.Message;
33 }
34 return str;
35 }
mailAddress
邮件地址添加多个就可以了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
System.Web.Helpers下有
WebMail 静态类
System.Net.Mail下有
MailMessage 实例类
WebMail 静态类
System.Net.Mail下有
MailMessage 实例类
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
用的是using System.Net;吗?直接加收件人就可以,用;分开。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询