0
Hello, I want to send my emails as below:
[email protected];[email protected];
but it’s giving me a sending error, because it’s taking the semicolon of the last address, when I put the emails in this way [email protected];[email protected]
without the ;
I can send normally, but if the user type the ;
I need to do a treatment for this, which is what I’m not getting.
I’ll leave the code section below, from what I’ve tried to do, thank you.
mail.From = new MailAddress(email);
//EmailIsValid(destinatario);
//mail.To.Add(destinatario);
string[] multiplesSend = destinatario.Split(';');
foreach (var emails in multiplesSend)
{
string expression = "^[A-Za-z0-9\\._%-]+@[A-Za-z0-9\\.-]+\\.[A-Za-z]{2,4}(?:[;][A-Za-z0-9\\._%-]+@[A-Za-z0-9\\.-]+\\.[A-Za-z]{2,4}?)*";
if (Regex.IsMatch(destinatario, expression))
mail.To.Add(emails);
}
}
Diogo any questions about formatting see the link: https://answall.com/editing-help it is of utmost importance that you have this knowledge being a new user.
– novic
@Virgilionovic Thanks for the information!
– Diogo Magro