Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not getting notification from Office365 #47

Open
rashi2010 opened this issue Dec 2, 2019 · 0 comments
Open

Not getting notification from Office365 #47

rashi2010 opened this issue Dec 2, 2019 · 0 comments

Comments

@rashi2010
Copy link

rashi2010 commented Dec 2, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant