title: Read most recent e-mail from outlook using PowerShell
body: <p>I am trying to read my Outlook e-mail with the subject line "Automation" and process further with custom script. The below script reads the e-mail with the subject line but it reads the entire count of e-mail with the subject "Automation".</p>
  
  <p>I want to be able to read only the most recent e-mail and process only that specific e-mail content and mark the e-mail as unread. And then read the next new e-mail with the same subject and process only the specific content.</p>
  
  <pre><code>Add-type -assembly "Microsoft.Office.Interop.Outlook" | out-null
  $olFolders = "Microsoft.Office.Interop.Outlook.olDefaultFolders" -as [type]
  $outlook = new-object -comobject outlook.application
  $namespace = $outlook.GetNameSpace("MAPI")
  $folder = $namespace.getDefaultFolder($olFolders::olFolderInBox)
  $folder.items | where { $_.subject -match 'Automation' } | Select-Object -Property body
  </code></pre>
  
  <p>Let's say if I have 10 new e-mail with subject "Automation" process 10th e-mail and mark as read and continue to process from 9 to 1.</p>
  
  <p>How to achieve this?</p>