Powershell using Outlook.Application to pull out the mailbox details
$outlook = new-object -com Outlook.Application
$session = $outlook.Session
$session.Logon()
$inbox = $outlook.session.GetDefaultFolder(6)
$unreadCount = (%{$inbox.Items | where {$_.UnRead}}).Count
Write-Host $unreadCount
$ItemCount = (%{$inbox.Items }).Count
Write-Host $ItemCount
Thanks for this shell command, I was wondering if you can help me alter this command so it checks every 30 minutes on an inbox for a user to see if there is an unread email older then 30 minutes and if so send an email alert? thanks in advance!
Thanks for this shell command, I was wondering if you can help me alter this command so it checks every 30 minutes on an inbox for a user to see if there is an unread email older then 30 minutes and if so send an email alert? thanks in advance!
Reply
This modification works for situations where 1 is returned as the result:
$outlook = new-object -com Outlook.Application
$session = $outlook.Session
$session.Logon()
$inbox = $outlook.session.GetDefaultFolder(6)
[array]$unreadCount = @(%{$inbox.Items | where {$_.UnRead}}).Count
Write-Host $unreadCount
[array]$ItemCount = @(%{$inbox.Items }).Count
Write-Host $ItemCount