| Visual Basic (Declaration) | |
|---|---|
Public Overloads Function Set( _ ByVal first As ImapMessage, _ ByVal last As ImapMessage, _ ByVal operation As ImapFlagModifier, _ ByVal flags As ImapFlags _ ) As ImapResponse | |
| Visual Basic (Usage) | Copy Code |
|---|---|
Dim instance As Mailbox Dim first As ImapMessage Dim last As ImapMessage Dim operation As ImapFlagModifier Dim flags As ImapFlags Dim value As ImapResponse value = instance.Set(first, last, operation, flags) | |
| C# | |
|---|---|
public ImapResponse Set( ImapMessage first, ImapMessage last, ImapFlagModifier operation, ImapFlags flags ) | |
| Managed Extensions for C++ | |
|---|---|
public: ImapResponse* Set( ImapMessage* first, ImapMessage* last, ImapFlagModifier operation, ImapFlags flags ) | |
| C++/CLI | |
|---|---|
public: ImapResponse^ Set( ImapMessage^ first, ImapMessage^ last, ImapFlagModifier operation, ImapFlags flags ) | |
Parameters
- first
- An ImapMessage object representing the first message in the range to set.
- last
- An ImapMessage object representing the last message in the range to set.
- operation
- An ImapFlagModifier value specifying the operation to perform on the flags.
- flags
- An ImapFlags value specifying the flags to modify.
Return Value
An ImapResponse object encapsulating the response from the server.| Exception | Description |
|---|---|
| Dart.PowerTCP.Mail.ProtocolException | Bad IMAP protocol response received from server. |
| System.Net.Sockets.SocketException | The requested address is not valid in its context. |
| System.ArgumentOutOfRangeException | index was out of range |
| System.IndexOutOfRangeException | index was outside bounds of array |
| Dart.PowerTCP.Mail.InvalidParameterTypeException | Collection contains instances of wrong type of object |
The following example demonstrates using the Set method to change message flags.
| Visual Basic | Copy Code |
|---|---|
' Login to the server Imap1.Login(Server, User, Pass) ' Get the current mailbox in a short variable name so we don't have to type as much Dim Box As Mailbox = Imap1.CurrentMailbox Dim First As ImapMessage = Box.Messages(0) Dim Last As ImapMessage = Box.Messages(box.Messages.Count - 1) ' Add Flagged and Answered flags to messages Box.Set(First, Last, ImapFlagModifier.Add, ImapFlags.Flagged | ImapFlags.Answered) ' Refresh the mailbox. Box.Refresh() ' Logout Imap1.Logout() | |
| C# | Copy Code |
|---|---|
// Login imap1.Login(Server, User, Pass); // Get the current mailbox in a short variable name so we don't have to type as much Mailbox box = imap1.CurrentMailbox; ImapMessage first = box.Messages[0]; ImapMessage last = box.Messages[box.Messages.Count - 1]; // Add Flagged and Answered flags to messages box.Set(first, last, ImapFlagModifier.Add, ImapFlags.Flagged | ImapFlags.Answered); // Refresh the mailbox. box.Refresh(); // Logout imap1.Logout(); | |
The Mailbox.Set method sets the values of one or more flags on the messages represented by the ImapMessage objects contained within the range specified by first and last. This command results in an IMAP STORE command being issued to the server for each message. The command uses the UIDs of the messages in the collection to perform the set operation. The ImapMessage objects contained within messages must be within this mailbox.
This method is useful for bulk operations. If you would like to set a flag on a single message, use the properties of the ImapMessage object representing that message.
Target Platforms: Microsoft .NET Framework 2.0