我使用System.Net.Mail發送電子郵件在我的應用程序,但我有一個例外,我不知道什麼/問題在哪裏,以及如何解決它。在郵件頭中找到無效字符:';'在C#
的問題說,我有一些無效的字符:
An invalid character was found in the mail header: ';'.
我試圖谷歌沒有成功。
與電子郵件地址字符串是:
[email protected]; [email protected]; [email protected]; [email protected];
這裏是我的電子郵件發送代碼:
SmtpClient smtpClient = new SmtpClient("smtp.........");
System.Net.Mail.MailMessage mailMessagePlainText = new System.Net.Mail.MailMessage();
mailMessagePlainText.IsBodyHtml = true;
mailMessagePlainText.From = new MailAddress("[email protected]", "admin");
mailMessagePlainText.Subject = "test";
mailMessagePlainText.Body = "test";
mailMessagePlainText.To.Add(new MailAddress(List1.ToString(), ""));
mailMessagePlainText.Bcc.Add(new MailAddress("[email protected]", ""));
try
{
smtpClient.Send(mailMessagePlainText);
}
catch (Exception ex)
{
throw (ex);
}
可能的重複[發送電子郵件到多個收件人MailMessage](http://stackoverflow.com/questions/23484503/sending-email-to-multiple-recipients-with-mailmessage) – PMerlet
List1的值是什麼?它是你提到的電子郵件地址字符串嗎? – MeanGreen
@MeanGreen:是的,先生List1的值是電子郵件地址字符串:[email protected]; [email protected]; [email protected]; [email protected]; –