PowerTCP Mail for .NET
Update(Int32,Int32,Boolean,ImapFlags) Method
Example 




The first message in the range.
The number of messages to set.
Use true to add the flags and false to remove them.
ImapFlags value specifying the flag(s) to modify.
Updates flag values on a range of messages from this Mailbox on the server.
Syntax
Public Overloads Function Update( _
   ByVal startIndex As Integer, _
   ByVal length As Integer, _
   ByVal set As Boolean, _
   ByVal flags As ImapFlags _
) As ImapResponse
Dim instance As Mailbox
Dim startIndex As Integer
Dim length As Integer
Dim set As Boolean
Dim flags As ImapFlags
Dim value As ImapResponse
 
value = instance.Update(startIndex, length, set, flags)
public ImapResponse Update( 
   int startIndex,
   int length,
   bool set,
   ImapFlags flags
)
public: ImapResponse* Update( 
   int startIndex,
   int length,
   bool set,
   ImapFlags flags
) 
public:
ImapResponse^ Update( 
   int startIndex,
   int length,
   bool set,
   ImapFlags flags
) 

Parameters

startIndex
The first message in the range.
length
The number of messages to set.
set
Use true to add the flags and false to remove them.
flags
ImapFlags value specifying the flag(s) to modify.

Return Value

ImapResponse encapsulating the response from the server.
Exceptions
ExceptionDescription
ProtocolExceptionBad IMAP protocol response received from server.
System.Net.Sockets.SocketExceptionA communications failure has occurred.
System.ArgumentOutOfRangeExceptionindex was out of range
System.IndexOutOfRangeExceptionindex was outside bounds of array
Remarks
Sets or resets the values of one or more flags on the specified messages. Update can be used to update flags on a single message. Update(ImapMessage[],Boolean,ImapFlags) can be used to update a list of messages.
Example
The following example demonstrates setting the delete flag on a range or set of messages, and optionally deleting them immediately.
/// <summary>
/// Sets the delete flag on a range of messages, and optionally deletes them immediately.
/// </summary>
/// <param name="myImap">A connected and authenticated Imap instance.</param>
/// <param name="startIndex">The index of the first message to delete. Corresponds to the index of the message in myImap.SelectedMailbox.</param>
/// <param name="length">The number of messages after startIndex to delete.</param>
/// <param name="purge">True to delete immediately. False to not delete immediately; wait until logout or a subsequent call to Purge().</param>
public void DeleteMessages(Imap myImap, int startIndex, int length, bool purge)
{
    myImap.SelectedMailbox.Update(startIndex, length, true, ImapFlags.Deleted);

    if (purge)
        myImap.SelectedMailbox.Purge();
}

/// <summary>
/// Sets the delete flag on the specified messages, and optionally deletes them immediately.
/// </summary>
/// <param name="myImap">A connected and authenticated Imap instance.</param>
/// <param name="messages">An array of messages from myImap.SelectedMailbox to delete.</param>
/// <param name="purge">True to delete immediately. False to not delete immediately; wait until logout or a subsequent call to Purge().</param>
public void DeleteMessages(Imap myImap, ImapMessage[] messages, bool purge)
{
    myImap.SelectedMailbox.Update(messages, true, ImapFlags.Deleted);

    if (purge)
        myImap.SelectedMailbox.Purge();
}
''' <summary>
''' Sets the delete flag on a range of messages, and optionally deletes them immediately.
''' </summary>
''' <param name="myImap">A connected and authenticated Imap instance.</param>
''' <param name="startIndex">The index of the first message to delete. Corresponds to the index of the message in myImap.SelectedMailbox.</param>
''' <param name="length">The number of messages after startIndex to delete.</param>
''' <param name="purge">True to delete immediately. False to not delete immediately; wait until logout or a subsequent call to Purge().</param>
Public Sub DeleteMessages(ByVal myImap As Imap, ByVal startIndex As Integer, ByVal length As Integer, ByVal purge As Boolean)
    myImap.SelectedMailbox.Update(startIndex, length, True, ImapFlags.Deleted)

    If purge Then
        myImap.SelectedMailbox.Purge()
    End If
End Sub

''' <summary>
''' Sets the delete flag on the specified messages, and optionally deletes them immediately.
''' </summary>
''' <param name="myImap">A connected and authenticated Imap instance.</param>
''' <param name="messages">An array of messages from myImap.SelectedMailbox to delete.</param>
''' <param name="purge">True to delete immediately. False to not delete immediately; wait until logout or a subsequent call to Purge().</param>
Public Sub DeleteMessages(ByVal myImap As Imap, ByVal messages() As ImapMessage, ByVal purge As Boolean)
    myImap.SelectedMailbox.Update(messages, True, ImapFlags.Deleted)

    If purge Then
        myImap.SelectedMailbox.Purge()
    End If
End Sub
See Also

Reference

Mailbox Class
Mailbox Members
Overload List


PowerTCP Mail for .NET Documentation Version 4.3
© 2018 Dart Communications. All Rights Reserved.
Send comments on this topic