ImapExpunge Method |
Namespace: MailBee.ImapMail
Exception | Condition |
---|---|
MailBeeException | An error occurred and ThrowExceptions is true. |
This overload can be used to expunge all messages marked as deleted from the current folder without closing it.
To expunge only certain messages (so that some messages having \Deleted flag set would remain), the developer should use Expunge(String, Boolean) overload.
To expunge deleted messages asynchronously, see the sample code in BeginExecuteCustomCommand(String, String, AsyncCallback, Object) topic.
using System; using MailBee; using MailBee.ImapMail; class Sample { static void Main(string[] args) { Imap imp = new Imap(); // Connect to the server and log in the account. imp.Connect("imap.domain.com"); imp.Login("jdoe@domain.com", "secret"); // Select Sent folder. imp.SelectFolder("Sent"); // Mark last 10 messages as deleted. if (imp.MessageCount >= 10) { string range = (imp.MessageCount - 9).ToString() + ":" + imp.MessageCount.ToString(); imp.SetMessageFlags(range, false, SystemMessageFlags.Deleted, MessageFlagAction.Add); } // Expunge all messages marked as deleted. imp.Expunge(); imp.Disconnect(); } }