ImapExpunge Method
Permanently removes all the messages marked as deleted from the currently selected folder.

Namespace: MailBee.ImapMail
Assembly: MailBee.NET (in MailBee.NET.dll) Version: 12.2.0 build 630 for .NET 4.5
public bool Expunge()

Return Value

Type: Boolean
true if the command succeeded; otherwise, false.
MailBeeExceptionAn 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.

This sample removes last 10 messages from Sent folder. If there were another messages marked as deleted in this folder, they will be removed as well.
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.Login("", "secret");

        // Select Sent folder.

        // 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.

See Also