Powershell - SEARCHING OUTLOOK INBOX

SEARCHING OUTLOOK INBOX


#### CONECTION TO MAILBOX ####
$olFolderInbox = 6
$outlook = new-object -com outlook.application;
$mapi = $outlook.GetNameSpace("MAPI");
$inbox = $mapi.GetDefaultFolder($olFolderInbox)

$inbox.items | foreach {
#  CHANGE "something" IN THE SUBJECT TO WHATEVER YOU LIKE
        if($_.subject -match "something") {...}
#  CHANGE "something" IN THE BODY TO WHATEVER YOU LIKE
        if($_.body -match "something") {...}
}