Unselects the currently selected folder and removes all messages having \Deleted flag set from the folder.
true if the folder was unselected successfully; otherwise, false.
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 method should be called.
| Exception Type | Condition |
|---|---|
| MailBeeException | An error occurred and ThrowExceptions is true. |
This sample marks the first message in Sent folder as deleted, and then closes this folder expunging deleted messages.
[C#] 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(); } }
[Visual Basic] Imports System Imports MailBee Imports MailBee.ImapMail Module Sample Sub Main(ByVal args As String()) ' The actual code (put it into a method of your class) Dim imp As New Imap ' Connect to the server and log in the account. imp.Connect("imap4.company.com") imp.Login("jdoe@company.com", "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() End Sub End Module
Imap Class | MailBee.ImapMail Namespace | Imap.Close Overload List | Disconnect | Expunge