/* Example of broken parsing in System.Net.Mail.MailAddress under Microsoft .Net Framework 2.0 */ /* Test-case written by Andreas Henriksson , 2007-03-28 */ using System.Net.Mail; class SmtpTest { public static void Main(string[] args) { /* valid from address, see RFC821 - 3.6 Relaying ** Used for Non-delivery reports and similar where you don't want a reply */ string from="<>"; string to="andreas@fatal.se"; /* the next line throws a "FormatException" in MS.Net 2.0 (Visual Studio 2005) on WinXP, ** even though the from address is valid. ** Tested (works) in Mono 1.2.2.1 on Debian */ MailAddress f = new MailAddress(from); MailAddress t = new MailAddress(to); MailMessage msg = new MailMessage(f, t); msg.Subject = "smtp-test"; msg.Body = "Testing smtpclient."; SmtpClient s = new SmtpClient("mail.fatal.se"); s.Send(msg); } }