SetFlagsForMessage Method


Sets the flags for a message in the currently selected mailbox.

To set flags for an arbitrary set of messages, specify MessageSet property and pass -1 as Index value. AsUID parameter is still honored when IDs are taken from MessageSet property (depending on AsUID value, they will be treated as UIDs or ordinal message numbers).

To use non-standard flags (like $Spam if it's supported by your IMAP server), use SetFlagsForMessageAsString method.


blnResult = ObjectName.SetFlagsForMessage(Index, AsUID, Flags, Action)  
Parameters:  
Index As Long Message number of Unique-ID of the message to set flags for, or -1 to use MessageSet as input.  
AsUID As Boolean If False, Index is a message number. If True, Index is a Unique-ID.  
Flags As Long Flags to be set for the message. Can be zero or any combination of the following:
  • 1 - Answered
  • 2 - Deleted
  • 4 - Draft
  • 8 - Flagged
  • 16 - Recent
  • 32 - Seen
 
Action As Long Indicates what to do with flags. Can be one of the following:
  • 1 - Set specified flags for the message
  • 2 - Remove specified flags from the message
  • 3 - Replace any existing flags with specified flags
 
Return value As Boolean True if successful, False if error has occurred  

Usage example:

Dim Mailer
'Using visual basic to create object
Set Mailer = CreateObject("MailBee.IMAP4")
'Using ASP to create object
'Set Mailer = Server.CreateObject("MailBee.IMAP4")
'In ASP use Response.Write instead of MsgBox

Mailer.EnableLogging = True ' Logging helps discover any problems
Mailer.LogFilePath = "C:\Temp\imap4_log.txt"

Mailer.LicenseKey = "put your license key here"
If Mailer.Connect("mailserver.com", 143, "MyName", "MyPassword") Then

  If Mailer.SelectMailbox("Inbox") Then

    ' Remove 'Answered' and 'Deleted' flags for the first message
    If Mailer.SetFlagsForMessage(1, False, 1 + 2, 2) Then
      MsgBox "Removed 'Answered' and 'Deleted' flags for message #1"
    End If

  End If

  Mailer.Disconnect
Else
  MsgBox Mailer.ErrDesc
End If

See Also:

DeleteMessages Method
SetFlagsForMessageAsString Method


Copyright © 2002-2022, AfterLogic Corporation. All rights reserved.