如何使用 System.Net.Mail 将电子邮件发送到多个地址
我有 smtp 电子邮件功能。它适用于单个地址,但在多个地址中存在问题。
我使用以下代码行传递多个地址。
MailAddress to = new MailAddress("[email protected],[email protected]");
请让我知道问题,因为我没有收到任何错误。
I have smtp email functionality. it works for single address but has problem in multiple address.
i am passing multiple addresses using following line of code.
MailAddress to = new MailAddress("[email protected],[email protected]");
Please let me know the problem as i am not getting any error.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(9)
To
是一个MailAddressCollection
,因此您可以添加所需的地址数量。如果您需要显示名称,请尝试以下操作:
To
is aMailAddressCollection
, so you can add how many addresses you need.If you need a display name, try this:
试试这个..
try this..
我认为您可以使用此代码以使传出地址列表具有显示名称(也不同):
I think you can use this code in order to have List of outgoing Addresses having a display Name (also different):
StewieFG 建议是有效的,但如果您想添加收件人姓名,请使用此名称,以及 Marco 上面发布的内容,但首先是电子邮件地址,其次是显示名称:
StewieFG suggestion is valid but if you want to add the recipient name use this, with what Marco has posted above but is email address first and display name second:
我的代码解决这个问题:
My code to solve this problem:
我使用“for”运算符。
I'm used "for" operator.