I am using the following in c# .NET to send out emails when a user fills out an online form.
I was wondering if threading is necessary for what I have.
MailAddress From = new MailAddress("xyz@qinc.com");
MailAddress To = new MailAddress(toemail);
MailMessage alert = new MailMessage(From, To);
alert.Subject = "Registration for " + name;
alert.Body = bodyText;
alert.IsBodyHtml = true;
NetworkCredential creds = new NetworkCredential("bot@qinc.com", "Xfdfdfd");
SmtpClient client = new SmtpClient("smtp.gmail.com");
client.EnableSsl = true;
client.Credentials = creds;
client.Send(alert);
Thanks in advance
If you have some sort of attachments embedded in the email AND/OR your email is HTML type and is quite large, and your bandwidth is low, I suggest you put that function into a thread to keep your application as responsive.
Threads improve responsiveness of the application, which puts the slow, time-consuming, BLOCKING tasks in a separate vessel(I like this analogy) and does not allow your application to sink. Users hate “This program is not responding” programs.