SMTP send email source code

private void btnSend_Click(object sender, EventArgs e) { try { SendEmail(txtSMTPServer.Text, Convert.ToInt32(txtSMTPPort.Text), txtSMTPUserName.Text, txtSMTPPassword.Text, txtFromEmailID.Text, txtToEmailID.Text, txtSubject.Text, txtBody.Text); } catch (Exception ex) { MessageBox.Show(ex.Message); } } void SendEmail(string SMTPServer, int SMTPPort, string SMTPUserName, string SMTPPassowrd, string FromEmailID, string ToEmailID, string Subject, string Body) { try { SmtpClient SmtpClient = new SmtpClient(SMTPServer, SMTPPort); SmtpClient.UseDefaultCredentials = false; SmtpClient.DeliveryMethod = SmtpDeliveryMethod.Network; SmtpClient.Credentials = new System.Net.NetworkCredential(SMTPUserName, SMTPPassowrd); MailMessage mailMsg = new MailMessage(); mailMsg.From = new MailAddress(FromEmailID); mailMsg.To.Add(ToEmailID); mailMsg.Subject = Subject; mailMsg.Body = Body; mailMsg.IsBodyHtml = true; SmtpClient.Send(mailMsg); } catch { throw; } }

Here I am posting the source code for Sending email using SMTP and C#.net