Ich habe einen kleinen Schnipsel schrieb die Funktion zu testen:
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);
}
}
mit den folgenden Ergebnissen auf 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]
Auch ist es nicht zu unterstützen „scheint quoted-string "Local-Teile, wie "blah"@example.com
.
Ich glaube nicht, dass ein Validator weniger akzeptieren könnte, bevor er unbrauchbar wird.
Holen Sie sich RedGate's Reflector und installieren Sie es, navigieren Sie dann zum Namespace System.Net.Mail und sehen Sie sich den Code an, um zu sehen, was er tut. Ich würde das machen, aber ich bin jetzt zu Hause auf meinem Mac. – tvanfosson
Vielleicht bin ich seltsam, aber ich würde lieber ein Dokument (vorzugsweise von MS oder ECMA) sehen, das besagt, dass das verdammte Ding "akzeptiert RFCs-und-wie Adressen mit Ausnahme der Abschnitte X, Y und Z, weil die IETF nicht weiß Sh * t über das Internet "als das Ding zerlegen zu müssen. –
Einverstanden, aber ohne solche Dokumentation - und vielleicht sogar damit - würde der Code die Frage definitiv beantworten. – tvanfosson