title: How select email items in a date range using VBA?
body: <p>How do I select email items using a specific date range? The user updates a date range via InputBox and emails to be selected automatically.</p>
  <p>I tried the below code.</p>
  <pre class="lang-vb prettyprint-override"><code>Sub getEmailsSelected()
      
      Dim myOlSel As Outlook.Selection
      Dim myOlExp As Outlook.Explorer
      Dim gtStartDate As String
      Dim gtEndDate As String
      
      gtStartDate = InputBox(&quot;Type the start date (format MM/DD/YYYY)&quot;)
      gtEndDate = InputBox(&quot;Type the end date (format MM/DD/YYYY)&quot;)
      
      Set myOlExp = Application.ActiveExplorer
      Set myOlSel = myOlExp.Selection(&quot;[Received] &gt;= '&quot; &amp; gtStartDate &amp; &quot;' And [Received] &lt;= '&quot; &amp; gtEndDate &amp; &quot;'&quot;)
      
  End Sub
  </code></pre>