using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using System.Net; namespace WindowsFormsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { Timer timer = new Timer(); timer.Interval = 10000; timer.Enabled = true; timer.Tick += timer_Tick; } void timer_Tick(object sender, EventArgs e) { try //Try and connect to a website { using (var client = new WebClient()) { using (var stream = client.OpenRead("http://www.google.com")) { // Connected, do stuff here // sendMail(); } } } catch (Exception ex) { //It failed so now we do nothing } } } }