System.Net.Mail.MailAddress

编程入门 行业动态 更新时间:2024-10-26 22:16:16
本文介绍了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

本文发布于:2023-11-07 14:58:13,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1566758.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Net   System   MailAddress   Mail

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!