Send email to multiple recipients

Asked

Viewed 737 times

1

I have a class to send email, which works perfectly for only one recipient, but I need to send it to several people, I made a select that searches the necessary emails and puts the ";". But when I try to send this way, it returns the error "An invalid character was found in the email header: ';'." I tried to put "," returns the same error.

I tried to do so:

 var listaEmail = emailDestinatario;
                var emails = listaEmail.Split(',');

                foreach (var endereco in emails)
                {
                    email.To.Add(endereco);
                }

It does not return error, but also does not send the emails. Any suggestions?

  • 1

    https://stackoverflow.com/questions/23484503/sending-email-to-multiple-recipients-with-mailmessage

  • What is the value of: listaEmail?

1 answer

2


listemail is receiving all the emails you want to send by separating with ",". if you are

Try to do it this way:

                string[] emails = listaEmail.Split(',');

                foreach (var endereco in emails)
                {
                    email.To.Add(endereco);
                }

Browser other questions tagged

You are not signed in. Login or sign up in order to post.