Hi
i have a problem with the code below. the mail is sent with a duplicate content of the string s. why is this happening?
static void Main(string[] args)
{
List<String> liste = new List<String>();
liste.Add("1");
liste.Add("2");
liste.Add("3");
liste.Add("4");
liste.Add("5");
liste.Add("6");
foreach(string s in liste)
new Thread(x => SendMail(s)).Start();
}
static void SendMail(string s)
{
MailMessage mailMsg = new MailMessage("from", "to");
mailMsg.Body = s;
mailMsg.Subject = s;
SmtpClient smtpClient = new SmtpClient("mySMTP");
smtpClient.UseDefaultCredentials = false;
smtpClient.Credentials = new NetworkCredential("myUse", "myPass");
smtpClient.EnableSsl = true;
try
{
smtpClient.Send(mailMsg);
}
catch (SmtpException ex)
{
Console.WriteLine(ex.Message);
}
}