I have an app where users can send emails to other users by selecting names from a list. There's also a textbox where they can freely enter a list of email addresses to Cc. Currently, each address to Cc is validated by an extensive regular expression, which checks conformance to RFC2822. The address is then added to the System.Net.Mail.MailMessage.CC
collection, something like this...
MailMessage message = new MailMessage(/*...*/);
//foreach address ...
{
try
{
MailAddress address = new MailAddress(strAddress);
message.CC.Add(address);
}
catch (FormatException fe)
{
// display error to user, don't sent the message
return false;
}
}
//send the message ...
My question is this - is there any point validating each address with a regex, or should I just rely on System.Net.Mail.MailAddress
to do the validation for me?