Home Tips+Tricks Programming Setting follow up by mouse click

Newsflash

Is software from outlook-stuff.com freeware?

 Read more...
Setting follow up by mouse click Print E-mail

If you need often the follow up function you can save clicks and time with the following code:

To use this example please read the important notes and have a look to the workshop Use VBA in Outlook®.

Option Explicit

Public Sub SetFlag()

    '=====================================================================
    ' Set the follow up mark to all selected e-mails
    ' (c) 2007-2008 Peter Marchert - http://www.outlook-stuff.com
    '=====================================================================

    Dim objMail         As Outlook.MailItem   ' Single e-mail
    Dim strRequest      As String             ' Text for the marking
    Dim lngFlagColor    As Long               ' Flag color
    Dim lngItem         As Long               ' Counter
    Dim lngItems        As Long               ' Number of the selected e-mails

    '---------------------------------------------------------------------
    ' Set the marking text
    '---------------------------------------------------------------------
    strRequest = "Follow up"
    
    '---------------------------------------------------------------------
    ' Set flag color (Outlook® 2003 and higher)
    ' 1 = Purple; 2 = Orange; 3 = Green; 4 = Yellow; 5 = Blue; 6 = Red
    '---------------------------------------------------------------------
    lngFlagColor = 3
    
    '---------------------------------------------------------------------
    ' Get the number of selected e-mails
    '---------------------------------------------------------------------
    lngItems = ActiveExplorer.Selection.Count

    '---------------------------------------------------------------------
    ' Proceed e-mails
    '---------------------------------------------------------------------
    For lngItem = 1 To lngItems
        
        '-----------------------------------------------------------------
        ' Reference an e-mail
        '-----------------------------------------------------------------
        Set objMail = ActiveExplorer.Selection(lngItem)
        
        '-----------------------------------------------------------------
        ' Set properties and save the e-mail
        '-----------------------------------------------------------------
        With objMail
            .FlagRequest = strRequest   ' Follow up text
            .FlagStatus = olFlagMarked  ' Follow up marking
            .FlagIcon = lngFlagColor    ' Flag color
            .Save
        End With
    
        '-----------------------------------------------------------------
        ' Clear reference to the e-mail
        '-----------------------------------------------------------------
        Set objMail = Nothing

    Next
    
End Sub