title: Not reading all mailitems from Inbox
body: <p>PLease see code below.  The subroutine I've written is supposed to look at all the emails that have come in just today and move only those that have the subject "daily stats".  I've deliberately sent two emails to myself with the subject "daily stats".  There is one other email in the Inbox that doesn't have the appropriate subject.  In all there are three emails.  When the Sub MoveHarpStatMail runs, it only moves one of the right emails with the subject "daily stats".  The other one seems to be ignored.  Is there something screwy with my filter string?  I've used the exact same filter string in another subroutine and it works perfectly fine there, reading in all the emails that came in just today.  I think I need another pair of eyes that will point out where I've gone wrong.</p>
  
  <p>Alan</p>
  
  <pre><code>Public StatsArchiveFolder As Outlook.Folder
  'StatsArchiveFolder is set elsewhere in another subroutine
  Public Const SubjectTitle As String = "daily stats"
  _______________________________________________
  
  Sub MoveHarpStatMail()
  
  Dim olapp As Outlook.Application
  Dim olappns As Outlook.NameSpace
  Dim oitem As Object
  Dim ItemsToProcess As Outlook.Items
  Dim myFolder As MAPIFolder
  Dim sFilter As String
  Dim tempMailItem As Outlook.MailItem
  
  On Error GoTo LocalErr
  
  'set outlook objects
  
  Set olapp = New Outlook.Application
  Set olappns = olapp.GetNamespace("MAPI")
  Set myFolder = olappns.GetDefaultFolder(olFolderInbox)
  'Filter for only MailItems received today
  sFilter = "[ReceivedTime] &gt;= " &amp; AddQuotes(Format(Date, "ddddd"))
  Set ItemsToProcess = Session.GetDefaultFolder(olFolderInbox).Items.Restrict(sFilter)
  
  For Each oitem In ItemsToProcess
   If TypeName(oitem) = "MailItem" Then
     Set tempMailItem = oitem
     Debug.Print tempMailItem.Subject
     If CheckSubject(tempMailItem.Subject) Then
       MoveToArchiveFolder tempMailItem
     End If
   End If
  Next oitem
  
  ExitProc:
  Set olapp = Nothing
  Set olappns = Nothing
  Set myFolder = Nothing
  Set ItemsToProcess = Nothing
  
  Exit Sub
  
  LocalErr:
      If Err.Number &lt;&gt; 0 Then
       Msg = "Sub MoveHarpStatMail" &amp; vbCrLf &amp; "Error # " &amp; Str(Err.Number) &amp; " was generated by " _
           &amp; Err.Source &amp; Chr(13) &amp; "Error Line: " &amp; Erl &amp; Chr(13) &amp; Err.Description
       MsgBox Msg, , "Error", Err.HelpFile, Err.HelpContext
       End If
  End Sub
  
  ____________________________________________
  
  Private Function AddQuotes(MyText) As String
    AddQuotes = Chr(34) &amp; MyText &amp; Chr(34)
  End Function
  
  _______________________________________________
  
  Sub MoveToArchiveFolder(Item As Outlook.MailItem)
  
      If StatsArchiveFolder Is Nothing Then
        MsgBox ("The ArchiveFolder object is not set.")
      End If
  
      Item.Move StatsArchiveFolder
  
  End Sub
  ________________________________________________
  
  Function CheckSubject(Subject As String) As Boolean
  
    If LCase(Trim(Subject)) = LCase(Trim(SubjectTitle)) Then
      CheckSubject = True
    Else
      CheckSubject = False
    End If
  
  End Function
  </code></pre>