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

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


Type: SystemString
A message sequence string containing ordinal message numbers or UIDs. Can be composed manually or using ToString.
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.
MailBeeExceptionAn error occurred and ThrowExceptions is true.

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.

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

        // Mark messages as deleted.
        imp.DeleteMessages("1,5:7", false);

        // Uncomment the next line to purge deleted messages.
        // imp.Close();

        // Disconnect from the server.
See Also