Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I send an email to multiple recipients using asp.net?

I have a sendmail funciton that works for one recipient. If I pass something like "[email protected];[email protected]" in ToEmail then I get an error that says ; not allowed in message header. What am I doing wrong?

Here is my SendMail function:

 Public Function SendMail(ByVal ToEmail As String, ByVal FromEmail As String, ByVal Subject As String, ByVal Body As String, Optional ByVal bccEmail As String = "", Optional ByVal bIsHTML As Boolean = False) As Boolean
    Try
        Dim msgMail As New MailMessage(FromEmail, ToEmail, Subject, Body)
        msgMail.IsBodyHtml = bIsHTML
        If bccEmail <> "" Then
            msgMail.Bcc.Add(bccEmail)
        End If
        Dim smtp As New SmtpClient
            smtp.Host = "myServer"

        smtp.Send(msgMail)
        SendMail = True
    Catch ex As Exception
        DoTrace(ex.Source, ex.Message)
        SendMail = False
    End Try
End Function
like image 772
user372234 Avatar asked Dec 16 '22 21:12

user372234


1 Answers

The addresses need to be separated with commas, not semicolons.

like image 135
tvanfosson Avatar answered Dec 26 '22 15:12

tvanfosson