C# Sending SMTP using System.Threading
Solved:
var SMTP = new SmtpClient { Host = txtBxSenderHost.Text, Port = 587, EnableSsl = true, DeliveryMethod = SmtpDeliveryMethod.Network, UseDefaultCredentials = false, Credentials = new NetworkCredential(strSenderAddress, strSenderPassword) }; Thread T1 = new Thread(delegate() { using (var message = new MailMessage(senderAdrress, toAddress) { Subject = strSubject, Body = strBody }) { { SMTP.Send(message); } } }); T1.Start();
You can do it even easier by defining everything beforehand and the just calling the new thread.
//define everything aboveThread t1 = new Thread(delegate(){ SMTP.send(message);});t1.Start();
Thats what I did and it makes life easier with those curly braces
Why not just use the Smtp.SendAsync method ?