是我还是System.Net.Mail中的MailAddress类有bug?
以下代码将始终抛出异常:
MailMessage mail = new MailMessage();
mail.From = new MailAddress("me@me.com");
mail.To.Add("joe-blow@me.com");
mail.Subject = "Test email"
mail.IsBodyHtml = true;
mail.Body = "<b>Does not work</b>";
//Connect to server and send message.
SmtpClient smtp = new SmtpClient();
smtp.Host = "mailserver.me.com";
smtp.Send(mail);
The exception I get is this:
System.FormatException: The specified string is not in the form required for an
e-mail address.
根据维基百科的说法,破折号是电子邮件地址中本地部分的有效字符。
有没有人知道如何使用System.Net.Mail类向电子邮件地址中包含破折号的人发送电子邮件?