I have the following code for sending mail and if you if you have a network connection it works perfectly.
MailMessage oMail = new MailMessage(new MailAddress("andr3yy.design@yahoo.com"), new MailAddress(setare[0].email));
oMail.Subject = "Subject";
oMail.Body = "Body";
SmtpClient oSmtp = new SmtpClient();
oSmtp.Host = "smtp.mail.yahoo.com";
oSmtp.Credentials = new NetworkCredential("andr3yy.design", "password");
oSmtp.EnableSsl = false;
oSmtp.Port = 587;
oSmtp.Send(oMail);
The probleme is: If you don't have a network connection and access this function, the application will crash. I don't want this to happen. I need a condition (if) to check if you are connected to internet, but I am new with C# and I don't know of one.