我有一个适用于一个收件人的sendmail功能.如果我在ToEmail中传递类似"email1@test.com; email2@test.com"的内容,则会收到错误消息:邮件标题中不允许.我究竟做错了什么?
这是我的SendMail功能:
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 …Run Code Online (Sandbox Code Playgroud)