ImapClose Method
Unselects the currently selected folder and removes all messages having \Deleted flag set from the folder.

Namespace: MailBee.ImapMail
Assembly: MailBee.NET (in MailBee.NET.dll) Version: 12.5.0 build 687 for .NET 4.5
Syntax
public bool Close()

Return Value

Type: Boolean
true if the folder was unselected successfully; otherwise, false.
Exceptions
ExceptionCondition
MailBeeExceptionAn error occurred and ThrowExceptions is true.
Remarks

To avoid expunging messages marked as deleted, the developer should not call this method and simply close the connection with Disconnect method. Another way is to select a different folder or simply unselect the current folder using Close(false) call.

To expunge messages marked as deleted without unselecting the current folder, Expunge(String, Boolean) method should be called.

Examples
This sample marks the first message in Sent folder as deleted, and then closes this folder expunging deleted messages.
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.company.com");
        imp.Login("jdoe", "secret");

        // Select Sent folder.
        imp.SelectFolder("Sent");

        // Mark message #1 as deleted.
        imp.SetMessageFlags("1", false,
            SystemMessageFlags.Deleted, MessageFlagAction.Add);

        // Close the folder and expunge deleted messages.
        imp.Close();

        // Disconnect from the server.
        imp.Disconnect();
    }
}
See Also