本文介绍了WebMail.Send()引发FormatException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试WebMail.Send()将邮件发送到多个电子邮件ID. MSDN库页明确指定应使用分号(;)分隔多个电子邮件ID.但是,当我尝试将邮件发送到多个ID时,出现消息提示FormatException在邮件标题中发现一个无效字符:';'.但是,如果我将邮件发送到单个收货人,邮件将被正确发送.

I am trying WebMail.Send() to send mail to multiple email ids. The MSDN library page clearly specifies that multiple email ids should be separated by semicolon(;). However when I try to send mails to multiple ids, I get FormatException with Message that says "An invalid character was found in the mail header: ';'. However if I send mail to single receipent, the mail gets delivered properly.

那么,如何使用WebMail.Send()将邮件发送到多个收货人?也许我缺少一些非常明显的东西.

So, how do I send mails to multiple receipents using WebMail.Send()? Perhaps I am missing something very obvious.

这是我正在使用的代码.

Here is the code that I am using.

string [] selectedUserIds = GetEmailIds();
string to = string.Join(";", selectedUserIds);
WebMail.Send(to: to, subject: subject, body: message, cc: cc, filesToAttach:   attachments, isBodyHtml:true);

推荐答案

我认为这是文档错误.分隔符适用于,.这是电子邮件地址的标准分隔符.

I think it is a documentation error. The delimiter works for ,. This is the standard delimiter for email addresses.

请参阅System.Net.Mail命名空间: http://msdn. microsoft.com/en-us/library/14k9fb7t.aspx -请参阅最后一条评论.

See for the System.Net.Mail namespace: http://msdn.microsoft.com/en-us/library/14k9fb7t.aspx - see the last comment.

这篇关于WebMail.Send()引发FormatException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 12:47