Guest User

Untitled

a guest
Aug 20th, 2018
466
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. Outlook Items.Restrict Does not return all messages
  2. [Reflection.Assembly]::LoadWithPartialname("Microsoft.Office.Interop.Outlook") | Out-Null
  3. $olFolders = "Microsoft.Office.Interop.Outlook.OlDefaultFolders" -as [type]
  4. $outlook = new-object -comobject outlook.application
  5. $namespace = $outlook.GetNameSpace("MAPI")
  6. $inbox = $namespace.getDefaultFolder($olFolders::olFolderInbox)
  7. $filter = "[SenderName] = 'Dummy Sender'"
  8. $messages = $inbox.items.Restrict($filter)
  9. $messages | % {
  10. Write-Host "`t$($_.Subject)"
  11. [void]$_.Move($destination) | Out-Null
  12. }
Add Comment
Please, Sign In to add comment