是我还是 System.Net.Mail 中的 MailAddress 类中存在错误?
此代码将始终抛出异常:
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);
我得到的例外是:
System.FormatException: The specified string is not in the form required for an
e-mail address.
但是,根据wiki,破折号是本地部分的有效字符。
有谁知道使用 System.Net.Mail 类向电子邮件地址中带有破折号的人发送电子邮件的方法?