FlagIcon Property

Microsoft Outlook Visual Basic

object.FlagIcon

object Required. An expression that returns one of the objects in the Applies To list.

olFlagIcon can be one of the following constants:

  • olNoFlagIcon (0)
  • olPurpleFlagIcon (1)
  • olOrangeFlagIcon (2)
  • olGreenFlagIcon (3)
  • olYellowFlagIcon (4)
  • olBlueFlagIcon (5)
  • olRedFlagIcon (6)

Remarks

Setting the FlagIcon property before sending an item will not set the flag on the item when the recipient receives it.

Example

The following Microsoft Visual Basic for Applications (VBA) example loops all items in a folder named Test in the Inbox and sets the yellow flag on items sent by Dan Wilson. To run this example without errors, make sure the Test folder exists in the default Inbox folder and replace 'Dan Wilson' with a valid sender name in the Test folder.

Sub SetFlagIcon()
    Dim myOlApp As Outlook.Application
    Dim mpfInbox As Outlook.MAPIFolder
    Dim obj As Outlook.MailItem
    Dim i As Integer
 
    Set myOlApp = CreateObject("Outlook.Application")
    Set mpfInbox = myOlApp.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox).Folders("Test")
 ' Loop all items in the Inbox\Test Folder
    For i = 1 To mpfInbox.Items.count
        If mpfInbox.Items(i).Class = olMail Then  
            Set obj = mpfInbox.Items.Item(i)
                If obj.SenderName = "Dan Wilson" Then
                'Set the yellow flag icon
                obj.FlagIcon = olYellowFlagIcon
                obj.Save
            End If
        End If
    Next
End Sub