Occurs when a notification message is received.

      Syntax

      public event EventHandler<TEventArgs> Update

      Examples

      Show how to handle the Update event.

      using System;
      using ComponentPro.Net.Mail;
      
      ...
      
      public void HandleUpdateEvent()
      {
          // Create a new instance. 
          Imap client = new Imap();
      
          client.Update += client_Update;
      
          // Connect to the IMAP server. 
          client.Connect("server");
      
          // Authenticate. 
          client.Authenticate("test", "test");
      
          // ... 
       
          while (!quit)
          {
              // Check for updates every 1 min. 
              client.CheckForUpdates();
      
              System.Threading.Thread.Sleep(60 * 1000); // Sleep 1 min. 
       
              // ... 
          }
      
          // ... 
       
          // Disconnect. 
          client.Disconnect();
      }
      
      void client_Update(object sender, ImapUpdateEventArgs e)
      {
          Console.WriteLine("New event: " + e.Event);
      }

      Shows how to handle Update event and use the Noop method to check for updates from the IMAP server.

      using System;
      using ComponentPro.Net;
      using ComponentPro.Net.Mail;
      
      ...
      
      static void Main()
      {
          // IMAP server information. 
          const string serverName = "imap.gmail.com";
          const string user = "username@gmail.com";
          const string password = "password";
          const int port = 993;
          const SslSecurityMode securityMode = SslSecurityMode.Implicit;
      
          // Create a new instance of the Imap class. 
          Imap client = new Imap();
      
          // Connect to the server. 
          client.Connect(serverName, port, securityMode);
      
          // Login to the server. 
          client.Authenticate(user, password);
      
          // Select 'INBOX' mailbox 
          client.Select("INBOX");
      
          client.Update += client_Update;
      
          // ... 
       
          while (!quit)
          {
              // ... 
       
              // Wait for 10 seconds. 
              client.CheckForUpdates(10000);
      
              // ... 
          }
      
          // ... 
       
          // Close the connection. 
          client.Disconnect();
      }
      
      static void client_Update(object sender, ImapUpdateEventArgs e)
      {
          switch (e.Event)
          {
              case ImapUpdateEvent.MessageCount:
                  Console.WriteLine("New message received.");
                  // You can download the newly received message here. 
                  break;
      
              case ImapUpdateEvent.MessageRemoved:
                  Console.WriteLine("One or more messages removed.");
                  break;
          }
      }

      Framework

      .NET Compact Framework.NET Compact Framework

      Supported version: 2.0, 3.5, and 3.9
      Assembly: ComponentPro.Mail.CF (in ComponentPro.Mail.CF.dll)

      .NET Framework.NET Framework

      Supported version: 2.0, 3.0, 3.5, 4.0, 4.5.x, 4.6.x and later
      Assembly: ComponentPro.Mail (in ComponentPro.Mail.dll)

      Xamarin AndroidXamarin Android

      Supported version: 2.3 and later
      Assembly: ComponentPro.Mail.Android (in ComponentPro.Mail.Android.dll)

      Xamarin MacXamarin Mac

      Supported version: 2.0.x and later
      Assembly: ComponentPro.Mail.Mac (in ComponentPro.Mail.Mac.dll)

      Xamarin iOSXamarin iOS

      Supported version: 5.1.x and later
      Assembly: ComponentPro.Mail.iOS (in ComponentPro.Mail.iOS.dll)

      See Also