title: Sort email with descending date
body: <p>I loop through all the emails to find the one with specific subject line.</p>
  
  <p>It always starts from the oldest one and is taking lot of time as mostly the mail required is the latest one.</p>
  
  <pre><code>Dim outMailItem As Outlook.MailItem
  Dim inputDate As String, subjectFilter As String
  Dim saveInFolder As   String
  Dim filesys, newfolder, newfolderpath
  OutlookOpened = False
  On Error Resume Next
  Set outApp = GetObject(, "Outlook.Application")
  If Err.Number &lt;&gt; 0 Then
  Set outApp = New Outlook.Application
  OutlookOpened = True
  End If
  On Error GoTo 0
  
  If outApp Is Nothing Then
  MsgBox "Cannot start Outlook.", vbExclamation
  Exit Sub
  End If
  
  Set outNs = outApp.GetNamespace("MAPI")
  
  Set outFolder = outNs.Folders("Personal Folders").Folders("Inbox")  
  'Set outFolder = outNs.PickFolder                                   
  Set outItems = outFolder.Items
  
  If Not outFolder Is Nothing Then
      outItems.Sort "[ReceivedTime]", False
      For Each outItems In outFolder.Items
          If outItems.Class = Outlook.OlObjectClass.olMail Then
  
              Set outMailItem = outItems
              randomdate = Format(outMailItem.SentOn, "dd/mm/yy")
              If outMailItem.Subject = subjectFilter Then
  
                  If randomdate = inputDate1 Then
  
                      Debug.Print outMailItem.Subject
                      For Each outAttachment In outMailItem.Attachments
                          outAttachment.SaveAsFile saveInFolder &amp; outAttachment.Filename
                      Next
                  End If
              End If
          End If
      Next
  </code></pre>
  
  <p>I have tried both True and False with sort order.</p>