title: Count of emails in outlook via powershell
body: <pre><code>$Outlook = New-Object -ComObject Outlook.Application  
  $OutlookInbox = $Outlook.session.GetDefaultFolder(6)  
  $TotalEmailCount = $OutlookInbox.ShowItemCount
  
  While ($TotalEmailCount -eq 0)  
      {  
              Start-Sleep -s 10  
              Write-Host "Waiting for the email"  
      }  
  Write-Host $TotalEmailCount
  </code></pre>
  
  <p>Initially the inbox folder is empty. Now am trying to wait till an email is received in the outlook and then print some "text" once it arrives. But when I try to run this code I always get the output as "1". Am using powershell. Any help please!</p>