// This is where all the magic happens.
 void timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
 {
     StatusBarText = "Connecting to server...";
     try
     {
         ImapClient ic = new ImapClient(ServerName, Username, Password, AuthMethods.Login, 993, true);
         ic.SelectMailbox("INBOX");
         Lazy<MailMessage>[] messages = ic.SearchMessages(SearchCondition.Unseen(), true, false);
         display.printNumber(messages.Length);
         StatusBarText = "Number of unread messages: " + messages.Length;
         ic.Disconnect();
         ic.Dispose();
     }
     catch (Exception ex)
     {
         StatusBarText = ex.Message;
         StopRunning();
     }
 }