0

我有一个包含数千封邮件的数据源,我需要做的是,它循环发送这封邮件,但是当邮件被列入黑名单或无效时,我收到一个错误,而其他邮件永远不会发送。

这很重要,因为后来的联系人永远不会收到我的传单,有可能忽略失败的邮件并继续发送吗?

这是我的代码的一部分:

 DataView dv = (DataView)contactosSource.Select(DataSourceSelectArguments.Empty);
        for (int i = 0; i < dv.Count; i++)
        {
            string correo = "" + dv[i][0];

            MailMessage m = new MailMessage();
            SmtpClient sc = new SmtpClient();

            m.From = new MailAddress("carlos.ancona@dotstudio.com", "Carlos Ancona");
            m.To.Add(new MailAddress(correo, correo));
            m.Subject = subjectLabel.Text;
            m.Body = "This is a Test Mail";

            String username = "SMTPusername";  
            String password = "password";

            sc.Host = "email-smtp.us-east-1.amazonaws.com";
            sc.Port = 587;
            sc.Credentials = new System.Net.NetworkCredential(username, password);
            //sc.UseDefaultCredentials = true;
            sc.EnableSsl = true;
            sc.DeliveryMethod = SmtpDeliveryMethod.Network;
            sc.Send(m);
        }
4

1 回答 1

0
try
{
    sc.Send(m);
}
catch
{
    Response.Clear();
    Response.Write(Encoding.UTF8.GetString(Convert.FromBase64String(@"WW91IHNodWxkIG5vdCBzcGFtIHBlb3BsZSE=")));
}
于 2012-11-12T09:28:07.003 回答