ImapSetMessageFlags Method (String, Boolean, SystemMessageFlags, MessageFlagAction) |
Sets or resets the specified flags for the specified messages in the currently selected folder.
Namespace: MailBee.ImapMailAssembly: MailBee.NET (in MailBee.NET.dll) Version: 12.5.0 build 687 for .NET 4.5
Syntax public bool SetMessageFlags(
string messageIndexSet,
bool indexIsUid,
SystemMessageFlags systemFlags,
MessageFlagAction action
)
Public Function SetMessageFlags (
messageIndexSet As String,
indexIsUid As Boolean,
systemFlags As SystemMessageFlags,
action As MessageFlagAction
) As Boolean
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. - systemFlags
- Type: MailBee.ImapMailSystemMessageFlags
A set of flags to be set or reset. - action
- Type: MailBee.ImapMailMessageFlagAction
The action to perform with the specified flags (set, reset, etc).
Return Value
Type:
Booleantrue if the message flags have been updated successfully; otherwise,
false.
Exceptions Remarks
To learn how to specify a valid message sequence (
messageIndexSet value), see
DownloadEnvelopes(String, Boolean) 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(String) method for that. |
Examples This sample undeletes all messages marked as deleted in the inbox folder.
using System;
using MailBee;
using MailBee.ImapMail;
class Sample
{
static void Main(string[] args)
{
Imap imp = new Imap();
imp.Connect("imap4.server.com");
imp.Login("jdoe@server.com", "secret");
imp.SelectFolder("INBOX");
UidCollection uids = (UidCollection)imp.Search(true, "DELETED", null);
if (uids.Count > 0)
{
imp.SetMessageFlags(uids.ToString(), true,
SystemMessageFlags.Deleted, MessageFlagAction.Remove);
}
imp.Disconnect();
}
}
Imports System
Imports MailBee
Imports MailBee.ImapMail
Module Sample
Sub Main(ByVal args As String())
Dim imp As New Imap
imp.Connect("imap4.server.com")
imp.Login("jdoe@server.com", "secret")
imp.SelectFolder("INBOX")
Dim uids As UidCollection = CType(imp.Search(True, "DELETED", Nothing), UidCollection)
If uids.Count > 0 Then
imp.SetMessageFlags(uids.ToString(), True, SystemMessageFlags.Deleted, MessageFlagAction.Remove)
End If
imp.Disconnect()
End Sub
End Module
See Also