开发者

.Net MailAddress fails on "ñ" in email address

开发者 https://www.devze.com 2023-01-30 16:19 出处:网络
The following code throws an exception of \"An invalid character was found in the mail header: \'ñ\'.\":

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

精彩评论

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