title: Count Followup Emails using Excel VBA
body: <p>I am using Office 2013 and I am trying to get a count of the followup items in one of my email folders and this value will be written into a cell.</p>
  
  <p>So I am using the below code after adding the Outlook Object Library reference:</p>
  
  <pre><code>Dim Folder As Outlook.MAPIFolder
  
  Dim objOL As Outlook.Application
  Set objOL = New Outlook.Application
  
  MailboxName = "mymailboxhere"
  Main_Folder_Name = "Inbox"
  Sub_Folder_Name = "Test"
  
  Set Folder = Outlook.Session.Folders(MailBoxName).Folders(Main_Folder_Name).Folders(Sub_Folder_Name)
  
  Dim itms As Outlook.Items
  Set itms = Folder.Items
  
  Dim FollowupItms As Outlook.Items
  Set FollowupItms = itms.Restrict("[FlagStatus] = 2")
  
  Followup = FollowupItms.Count
  Worksheets("Sheet1").Range("A1").Value = Followup
  </code></pre>
  
  <p>For some reason I keep getting the Followup count as <strong>0</strong> even though there is at least an email flagged as followup.</p>
  
  <p>To test I have tried the below:</p>
  
  <pre><code>For Each Msg In itms
  MsgBox Msg.FlagStatus
  Next
  </code></pre>
  
  <p>And the Flagstatus of one of the emails is <strong>2</strong> and the same shows in the Msgbox during the test.</p>
  
  <p>The code works fine when counting emails that are UnFlagged or emails that are marked as Completed.</p>
  
  <p>This makes absolutely no sense to me. Any thoughts?</p>