Is it me or is there an error in the MailAddress class in System.Net.Mail?
This code will always call excpetion:
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);
An exception I get the following:
System.FormatException: The specified string is not in the form required for an e-mail address.
However, according to the wiki , a dash is a valid character in the local part.
Does anyone know a way to use System.Net.Mail classes to send email to someone with a dash to an email address?
thorkia
source share