MailSystem.NET icon indicating copy to clipboard operation
MailSystem.NET copied to clipboard

Not getting notification from Office365

Open rashi2010 opened this issue 6 years ago • 0 comments

I have mentioned the code below which is working fine for Gmail but not giving any notification in case of outlook account.

     private void StartIdleProcess(object sender, DoWorkEventArgs e)
         {
         // Get the BackgroundWorker that raised this event.
         //BackgroundWorker worker = sender as BackgroundWorker;

         try
         {
             if (imap != null && imap.IsConnected)
             {
                 imap.StopIdle();
                 imap.Disconnect();
             }

             var handShake = new ActiveUp.Net.Security.SslHandShake("imap-mail.outlook.com", System.Security.Authentication.SslProtocols.Default);
             handShake.ServerCertificateValidationCallback = delegate { return true; };

             imap = new Imap4Client();
             imap.NewMessageReceived += new NewMessageReceivedEventHandler(NewMessageReceived);
          
             imap.ConnectSsl("imap-mail.outlook.com", 993);
             var res = imap.Login(@OutlookID, @Password);
             imap.SelectMailbox("inbox");
             imap.StartIdle();
             _log.Info("Connected");
         }
         catch (Exception ex)
         {
         }
     }

     public static void NewMessageReceived(object source, NewMessageReceivedEventArgs e)
     {
         //thisForm.AddLogEntry("New message received :" + e.MessageCount);
         _log.Info("Message Received");
         //imap4.StopIdle();
     }

After sometime it is giving "Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host." this exception.

rashi2010 avatar Dec 02 '19 11:12 rashi2010