Sandeep Vemula

Sandeep Vemula

  • NA
  • 569
  • 144.1k

Sending all mails from dataset

Feb 25 2012 5:09 AM
Hi, here am sending 999 mails per day.
so am getting prob while sending mail.
that is if any mail id is wrong the loop is quitting.
but i want to continue that loop until all mails i have to send.
this is my code.
(for example. these r mail ids.
[email protected], [email protected], a , abc, [email protected],[email protected].
so here am getting error at a contact. here my loop is quitting. so my req is if am get error (string is not format like this type error ) still i have to send remaining mails)
)

foreach (DataRow dr in ds.Tables[1].Rows ' here consider 999 mail ids')
  {
  smtpclient.Host = "s0002";
  MailMessage message = new MailMessage("[email protected]", dr["Email"].ToString());
  message.Body = ds.Tables[0].Rows[0]["MessageBody"].ToString();
  message.Subject = "Hi  Mr/Mrs,";
  smtpclient.Credentials = new System.Net.NetworkCredential("", "");
  smtpclient.Port = 25;
  smtpclient.Send(message);
  }

Answers (2)