本文介绍了System.Net.Mail.MailAddress的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好, 我正在尝试一次发送多封电子邮件,但无法做到.最初,我试图用;"分隔电子邮件地址.在我确定需要使用,"之后.此代码不会让我发送电子邮件有人可以帮忙吗?
Hello guys, I am trying to send multiple emails at a time but cant do it. At first I tried to seperate e-mail adress with ";" after I figured I needed to use "," instead. This code wont let me send email can someone help?
foreach (Rules rl in global_rules) { if (rl._ratingtype == "Equal to") { if (Convert.ToInt32(rating) == Convert.ToInt32(rl._rating)) { //message.To.Add(new System.Net.Mail.MailAddress(rl._mailto)); recipient = rl._mailto + "," + recipient; } } else if (rl._ratingtype == "Greater than and equal to") { if (Convert.ToInt32(rating) >= Convert.ToInt32(rl._rating)) { //message.To.Add(new System.Net.Mail.MailAddress(rl._mailto)); recipient = rl._mailto + "," + recipient; } } else if (rl._ratingtype == "Less than and equal to") { if (Convert.ToInt32(rating) <= Convert.ToInt32(rl._rating)) { //message.To.Add(new System.Net.Mail.MailAddress(rl._mailto)); recipient = rl._mailto + "," + recipient; } } } recipient = recipient.TrimEnd(','); message.To.Add(new System.Net.Mail.MailAddress(recipient));推荐答案
邮件对象的收件人"字段实际上是收件人的集合.无需尝试将所有收件人串联为一个字符串,只需将每个收件人单独添加即可,并且只要您的rl._mailto地址均有效,它就可以正常工作. The "To" field of the mail object is actually a collection of recipients. Instead of trying to concatenate all the recipients into 1 string, just add each one individually and it should work provided each of your rl._mailto addresses are valid.
更多推荐
System.Net.Mail.MailAddress
发布评论