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

This method lets you specify the flags as a space-separated string. You can use non-standard flags which are not supported by MailBee. Standard flags starts with "\" while non-standard can be of any kind.

Note that there is no guarantee your server will support such flags. Also, some servers accept non-standard flags but do not save their value on permanent basis (i.e. flag value is not persistent).


blnResult = ObjectName.SetFlagsForMessageAsString(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 String Flags to be set for the message. A string like "\Answered \Seen $Starred" (allows for non-standard flags if supported by the server).  
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

    ' Mark email as spam
    If Mailer.SetFlagsForMessage(1, False, "$Spam", 1) Then
      MsgBox "Email marked as spam with $Spam flag"
    End If

  End If

  Mailer.Disconnect
Else
  MsgBox Mailer.ErrDesc
End If

See Also:

DeleteMessages Method
SetFlagsForMessage Method


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