I have this method I wrote that sends an email when the user presses on a button. Now the problem I am facing is that whenever a user presses on the button, the form freezes for a couple of seconds and then sends the email. So the method is working but I don't understand why the form freezes.
string emailAddress = tbEmailAddress.Text + cbEmailAddress.Text;
string emailPassword = tbEmailPassword.Text;
string emailRecipient = tbEmailRecipient.Text;
string emailSubject = tbEmailSubject.Text;
string emailBody = rtbEmailBody.Text;
string smtpHost;
string smtpPort;
MailMessage email = new MailMessage(emailAddress, emailRecipient);
email.Subject = emailSubject;
email.Body = emailBody;
SmtpClient smtp = new SmtpClient("smtp.live.com", 587);
smtp.EnableSsl = true;
smtp.Credentials = new System.Net.NetworkCredential(emailAddress, emailPassword);
smtp.Send(email);
smtp.Dispose();
Is there any way to get around this problem I am facing?
Thank you in advance.