本文介绍了什么是System.Net.Mail.MailAddress'解析器接受的格式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我工作的这是一个使用系统的应用.Net.Mail.MailAddress 和朋友发送电子邮件。这是否解析器实现全 RFC5322 的子集或什么?在MSDN不是很即将举行的关于这一主题。

I'm working on an app that's using System.Net.Mail.MailAddress and friends for sending emails. Does that parser implement the full RFC5322 or a subset or what? The MSDN is not very forthcoming on this topic.

任何提示AP preciated。

Any hints appreciated.

推荐答案

我已经写了一个小片段来测试功能:

I've wrote a little snippet to test the function:

foreach (int i in Enumerable.Range(32,128-32))
{
    char c = (char)i;
    string addr = String.Format("par.t1{0}pa.r{0}[email protected]", c);
    try
    {
        var mailAddr = new MailAddress(addr);
    }
    catch
    {
        Console.WriteLine("MailAddress failed '{0}' ({1}): {2}", c, i, addr);
    }
}

随着3.5 SP1以下结果:

With the following results on 3.5 SP1:


MailAddress failed ' ' (32): par.t1 pa.r [email protected]
MailAddress failed '"' (34): par.t1"pa.r"[email protected]
MailAddress failed '(' (40): par.t1(pa.r([email protected]
MailAddress failed ')' (41): par.t1)pa.r)[email protected]
MailAddress failed ',' (44): par.t1,pa.r,[email protected]
MailAddress failed ':' (58): par.t1:pa.r:[email protected]
MailAddress failed ';' (59): par.t1;pa.r;[email protected]
MailAddress failed '<' (60): par.t1<pa.r<[email protected]
MailAddress failed '>' (62): par.t1>pa.r>[email protected]
MailAddress failed '@' (64): [email protected]@[email protected]
MailAddress failed '[' (91): par.t1[pa.r[[email protected]
MailAddress failed '\' (92): par.t1\pa.r\[email protected]
MailAddress failed ']' (93): par.t1]pa.r][email protected]
MailAddress failed '⌂' (127): par.t1⌂pa.r⌂[email protected]

此外,它似乎不支持引用字符串本地部分,如嗒嗒@ example.com

我不认为一个验证器可以接受任何减少变得不可用了。

I don't think a validator could accept any less before becoming unusable.

这篇关于什么是System.Net.Mail.MailAddress'解析器接受的格式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-16 19:44