C#C
C#3y ago
yumo

Error with app send email

The goal is to make a send emails app from c# , later on to also send with attachments but im stuck at this for the past 2 hours

As you can see in the image its saying the error is on line 52

Here is what i have done till now:
line 52 is the line
private void btnEnviar_Click(object sender, EventArgs e)
        {
            try
            {
                //Criar duas string s que contenham o email e a password

                string from = "myemailinfo";
                string password = "mypasswordhere";

                //Criar o objeto de acesso ah class mail
                MailMessage msg = new MailMessage();
                msg.Subject = txtAssunto.Text;
                msg.From = new MailAddress(from);
                msg.Body = txtMensagem.Text;
                msg.To.Add(new MailAddress(cmbEmail.Text));

                SmtpClient smpt = new SmtpClient();

                smpt.Host = "smpt.gmail.com";

                smpt.Port = 587;

                smpt.UseDefaultCredentials = false;

                smpt.EnableSsl = true;

                NetworkCredential nc = new NetworkCredential(from, password);

                smpt.Credentials = nc;

                smpt.Send(msg);

                MessageBox.Show("Email Enviado com sucesso!");
            }   
            catch(Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }


Can someone help me why is it saying this?
image.png
Was this page helpful?