I created a form which includes a Send button and a richtextbox and Username and Passsword and From and To textboxes.
This is the code in the send button but unfortunately the program will close when I fill in the textboxes and click on the send button.
 private void btnSend_Click(object sender, EventArgs e)
 {
     MailMessage mail = new MailMessage(from.Text, to.Text, Subject.Text, body.Text);
      // SmtoServer = smtp.company.com; Ex: Gmail . smtp.gmail.com | yahoo - smtp.yahoo.com
      SmtpClient client = new SmtpClient(smtp.Text);
      client.Port = 587;
      client.Credentials = new System.Net.NetworkCredential(username.Text,password.Text);
      client.EnableSsl = true;
      client.Send(mail);
      MessageBox.Show("Your mail has been sent!\n Thanks for your email",
                      "Success", MessageBoxButtons.OK);
 }
Update I tried whatever you said and i already watch the Youtube video but compiler show me error in the line 9 :
client.Send(mail);
and this is the error :
An unhandled exception of type 'System.Net.Mail.SmtpException' occurred in System.dll
Additional information: The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required.
