Marks the specified messages in the currently selected folder as deleted.
true if the messages have been marked as deleted successfully; otherwise, false.
To learn how to specify a valid message sequence (messageIndexSet value), see DownloadEnvelopes topic.
Note This method just sets "\Deleted" flag for the specified messages. To purge deleted messages permanently, call Expunge method or explicitly unselect the folder using Close method.
To learn now to undelete messages marked as deleted, see the sample in SetMessageFlags topic.
| Exception Type | Condition |
|---|---|
| MailBeeException | An error occurred and ThrowExceptions is true. |
This sample marks the first message and the messages #5, #6, and #7 in the inbox as deleted.
[C#] using System; using MailBee; using MailBee.ImapMail; class Sample { static void Main(string[] args) { Imap imp = new Imap(); // Connect to the server, login and select inbox. imp.Connect("mail.server.com"); imp.Login("jdoe", "secret"); imp.SelectFolder("INBOX"); // Mark messages as deleted. imp.DeleteMessages("1,5:7", false); // Uncomment the next line to purge deleted messages. // imp.Close(); // Disconnect from the server. imp.Disconnect(); } }
[Visual Basic] Imports System Imports MailBee Imports MailBee.ImapMail Module Sample Sub Main() Dim imp As New Imap ' Connect to the server, login and select inbox. imp.Connect("mail.server.com") imp.Login("jdoe", "secret") imp.SelectFolder("INBOX") ' Mark messages as deleted. imp.DeleteMessages("1,5:7", False) ' Uncomment the next line to purge deleted messages. ' imp.Close() ' Disconnect from the server. imp.Disconnect() End Sub End Module
Imap Class | MailBee.ImapMail Namespace