我使用System.Net.Mail.MailMessage从我的C#Windows应用程序发送电子邮件。已更改MailMessage属性,现在挂在客户端上。发送
我本来这样的:
MailMessage mail = new MailMessage("[email protected]", "[email protected]");
等,这工作得很好 - 但是我需要多张添加到地址,所以我改成了这样:
MailMessage mail = new MailMessage();
mail.From = new MailAddress("[email protected]");
foreach (string to in to_add)
{
if (to.Trim() != "")
{
mail.To.Add(to.Trim());
}
}
mail.Body = message;
mail.Subject = "Subject Text";
SmtpClient client = new SmtpClient("0.0.0.0");
client.UseDefaultCredentials = true;
client.Send(mail);
这段代码可以遍历几次,并且在字符串数组中至多会有3个To地址 - 第一次运行时,它很好 - 但随后第二次循环通过,它挂在
client.Send(mail);
我在这里错过了什么吗?这是我第一次使用MailMessage,所以很可能我错过了一些重要的东西。
干杯
莱迪
附:我没有使用IP地址“0.0.0.0”,出于安全原因,我刚删除了正确的IP地址。
我刚刚提出了一堆选项。哪一个帮助了? –