开发者

.Net MailAddress fails on "ñ" in email address

The following code throws an exception of "An invalid character was found in the mail header: 'ñ'.":

string email = "ñ@c.com";
MailAddress to = new MailAddress(email); 

The actual address I'm running开发者_开发百科 into this is a valid address, but the MailAddress class throws an error whenever I try and use it.


Yeah, interesting. According to Wikipedia: Email Address, it's strictly defined as being a subset of ASCII, so that is technically invalid.

So, it seems you just strictly can't send email to that address from .NET (using the System.Net.Mail classes, anyway).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜