ImapDeleteMessages Method
Marks the specified messages in the currently selected folder as deleted.

Namespace: MailBee.ImapMail
Assembly: MailBee.NET (in MailBee.NET.dll) Version: 12.5.0 build 687 for .NET 4.5
Syntax
public bool DeleteMessages(
	string messageIndexSet,
	bool indexIsUid
)

Parameters

messageIndexSet
Type: SystemString
A message sequence string containing ordinal message numbers or UIDs. Can be composed manually or using ToString.
indexIsUid
Type: SystemBoolean
If true, messageIndexSet is treated as a sequence of UIDs; otherwise, as a sequence of ordinal message numbers.

Return Value

Type: Boolean
true if the messages have been marked as deleted successfully; otherwise, false.
Exceptions
ExceptionCondition
MailBeeExceptionAn error occurred and ThrowExceptions is true.
Remarks

To learn how to specify a valid message sequence (messageIndexSet value), see DownloadEnvelopes(String, Boolean) topic.

Note Note
This method just sets "\Deleted" flag for the specified messages. To purge deleted messages permanently, call Expunge(String, Boolean) method or explicitly unselect the folder using Close(Boolean) method.

To learn now to undelete messages marked as deleted, see the sample in SetMessageFlags(String, Boolean, SystemMessageFlags, MessageFlagAction) topic.

Examples
This sample marks the first message and the messages #5, #6, and #7 in the inbox as deleted.
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();
    }
}
See Also