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.2.0 build 630 for .NET 4.5
public bool Close()

Return Value

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

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.

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.Login("jdoe", "secret");

        // Select Sent folder.

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

        // Close the folder and expunge deleted messages.

        // Disconnect from the server.
See Also