Attribute VB_Name = "FlagUnrepliedEmails"
Option Explicit

Public Sub FlagUnrepliedEmails()
    Dim olApp As Object, olNs As Object, olInbox As Object, olItem As Object
    Dim count As Long

    Set olApp = Application ' running from Outlook's VBA editor
    Set olNs = olApp.GetNamespace("MAPI")
    Set olInbox = olNs.GetDefaultFolder(6) ' olFolderInbox

    count = 0
    For Each olItem In olInbox.Items
        If olItem.Class = 43 Then ' olMail
            If olItem.ReceivedTime < Now - 2 And olItem.IsMarkedAsTask = False Then
                If InStr(1, olItem.Categories, "Replied") = 0 Then
                    olItem.FlagStatus = 2 ' olFlagMarked
                    olItem.FlagRequest = "Follow up"
                    olItem.Save
                    count = count + 1
                End If
            End If
        End If
    Next olItem

    MsgBox count & " message(s) flagged for follow-up.", vbInformation
End Sub