public static void NewMessageReceived(object source, NewMessageReceivedEventArgs e)
        {
            //thisForm.AddLogEntry("New message received :" + e.MessageCount);
            MessageBox.Show("New message received :" + e.MessageCount);

            //imap4.StopIdle();
        }
        /// <summary>
        /// Triggered when the client receives a new e-mail. 
        /// </summary>
        /// <param name="source"></param>
        /// <param name="e"></param>
        private void NewMessageReceived(object source, NewMessageReceivedEventArgs e)
        {
            //Write a new entry to the log file.
            serviceLog.WriteEntry("E-mail received!");

            //Stop idling and create a new connection with the server
            client.StopIdle();
            ConnectToServer();

            //Get all unread mails from the inbox
            List<Message> receivedEmails = GetUnreadMails("INBOX").ToList();

            //Send each mail to the IntelliCloud webservice
            foreach (Message mail in receivedEmails) 
            {
                serviceLog.WriteEntry("E-mail received from " + mail.From.Email);
                try
                {
                    CreateQuestion(mail);                    
                    SendConfirmationMail(mail.From);
                }
                catch (Exception ex)
                {
                    //If it fails send error to log file
                    serviceLog.WriteEntry("Sending question failed: " + ex.ToString());
                }
            }

            //Set the messagereceivedeventhandler for the client
            client.NewMessageReceived += new NewMessageReceivedEventHandler(NewMessageReceived);

            SubscribeToInbox();

            client.StartIdle();
        }