Sets or resets the specified flags for the specified messages in the currently selected folder.
true if the message flags have been updated successfully; otherwise, false.
To learn how to specify a valid message sequence (messageIndexSet value), see DownloadEnvelopes topic.
Note This method can also set Gmail-specific labels for messages (see MessageFlagAction topic for details). If the label contains international characters, you should encode it with UTF-7M unless it's already encoded. You can use ToUtf7QuotedString method for that.
| Exception Type | Condition |
|---|---|
| MailBeeException | An error occurred and ThrowExceptions is true. |
This sample undeletes all messages marked as deleted in the inbox folder.
[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("imap4.server.com"); imp.Login("jdoe@server.com", "secret"); imp.SelectFolder("INBOX"); // Get UIDs of deleted messages. We could have also skipped this // stage and just tell the server to remove \Deleted flag for // all messages (even for those message which do not have this // flag set - such messages won't be affected). We call Search() // method and then consume its results in SetMessageFlags() just // for purposes of illustration. UidCollection uids = (UidCollection)imp.Search(true, "DELETED", null); if (uids.Count > 0) { // Remove \Deleted flag from the deleted messages. imp.SetMessageFlags(uids.ToString(), true, SystemMessageFlags.Deleted, MessageFlagAction.Remove); } // Disconnect from the server. imp.Disconnect(); } }
[Visual Basic] Imports System Imports MailBee Imports MailBee.ImapMail Module Sample Sub Main(ByVal args As String()) Dim imp As New Imap ' Connect to the server, login and select inbox. imp.Connect("imap4.server.com") imp.Login("jdoe@server.com", "secret") imp.SelectFolder("INBOX") ' Get UIDs of deleted messages. We could have also skipped this ' stage and just tell the server to remove \Deleted flag for ' all messages (even for those message which do not have this ' flag set - such messages won't be affected). We call Search() ' method and then consume its results in SetMessageFlags() just ' for purposes of illustration. Dim uids As UidCollection = CType(imp.Search(True, "DELETED", Nothing), UidCollection) If uids.Count > 0 Then ' Remove \Deleted flag from the deleted messages. imp.SetMessageFlags(uids.ToString(), True, SystemMessageFlags.Deleted, MessageFlagAction.Remove) End If ' Disconnect from the server. imp.Disconnect() End Sub End Module
Imap Class | MailBee.ImapMail Namespace | Imap.SetMessageFlags Overload List