ImapServerStatus Event |
Namespace: MailBee.ImapMail
The server sends the status response to the client when a command is completed or there is a state change of the server or the currently folder, etc.
MailBee raises this event when it receives any of the following responses from the server: OK, NO, BAD, PREAUTH, BYE, or FLAGS.
The real-world application should subscribe to this event and at least check IsAlert property value. If it's true, it means the server sent [ALERT] response along with the human-readable message, and the application must present the supplied HumanReadable text to the user. For instance, the server may tell clients it's about to shutdown in a short while.
using System; using MailBee; using MailBee.ImapMail; class Sample { // ServerStatus event handler. private static void OnServerStatus(object sender, ImapServerStatusEventArgs e) { if (e.IsAlert) { Console.WriteLine("The server warns: " + e.HumanReadable); } } // The actual code. static void Main(string[] args) { Imap imp = new Imap(); // Subscribe to ServerStatus event. imp.ServerStatus += new ImapServerStatusEventHandler(OnServerStatus); // Connect to the server, login and select inbox. imp.Connect("mail.company.com"); imp.Login("jdoe", "secret"); imp.SelectFolder("INBOX"); // Download envelopes of all message in the inbox. EnvelopeCollection envs = imp.DownloadEnvelopes(Imap.AllMessages, false); imp.Disconnect(); } }