search
Categories
Sponsors
VirtualMetric Hyper-V Monitoring, Hyper-V Reporting
Archive
Blogroll

Badges
MCSE
Community

Cozumpark Bilisim Portali
Posted in Windows Powershell, Windows Server | No Comment | 3,524 views | 07/06/2009 09:45

You can check new mails with Powershell. But you need Outlook Connector.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
$InboxFolder = 6
$Outlook = new-object -com outlook.application;
$NameSpace = $Outlook.GetNameSpace("MAPI");
$Inbox = $NameSpace.GetDefaultFolder($InboxFolder)
$Inbox.items | foreach {
    if($_.body -match "Support") 
        {
            write-host You have a new mail.
        }
        else
        {
            write-host No new mail.
        }
}

By default, Inbox folder number is 6. You can change that number for other directories.