PowerTCP Mail for .NET
Set(ImapMessage,ImapMessage,ImapFlagModifier,ImapFlags) Method
See Also  Example Send comments on this topic.
Dart.PowerTCP.Mail Namespace > Mailbox Class > Set Method : Set(ImapMessage,ImapMessage,ImapFlagModifier,ImapFlags) Method




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.
Sets flag values on a range of messages.

Syntax

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)
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.

Exceptions

ExceptionDescription
Dart.PowerTCP.Mail.ProtocolExceptionBad IMAP protocol response received from server.
System.Net.Sockets.SocketExceptionThe requested address is not valid in its context.
System.ArgumentOutOfRangeExceptionindex was out of range
System.IndexOutOfRangeExceptionindex was outside bounds of array
Dart.PowerTCP.Mail.InvalidParameterTypeExceptionCollection contains instances of wrong type of object

Example

The following example demonstrates using the Set method to change message flags.
Visual BasicCopy 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();

Remarks

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.

Requirements

Target Platforms: Microsoft .NET Framework 2.0

See Also

Documentation Version 3.2
© 2010 Dart Communications. All Rights Reserved.