I am trying to add bulk mail list to addresses so that I can send that bulk mail list at a time.Here I have done this by looping into every record that returned from my dataset.Is there any better way to add that total dataset to the address list without looping.Thanks in advance.Here is my code
DataSet ds = new DataSet();
List<string> to = new List<string>();
//I have returned one dataset containing list of emails to be send.
ds = email.GetBulkProcessMails("Process");
//here I am looping through every record in the dataset and adding that records to my List
if (ds.Tables.Count > 0)
{
foreach (DataRow dtrow in ds.Tables[0].Rows)
{
tomailscount bmscount = new tomailscount();
bmscount.destinationmails = dtrow["tomail_id"].ToString();
to.Add(bmscount.destinationmails.ToString());
}
}
//Here I am assigning that entire list to address and adding that recipient for transmission
for (int i = 0; i < to.Count; i++)
{
var recipient = new Recipient
{
Address = new Address { Email = to[i] }
};
transmission.Recipients.Add(recipient);
}
//Here I am sending that transmission
var sparky = new Client(ConfigurationManager.AppSettings["APIKey"]);
sparky.Transmissions.Send(transmission);