Skip to content

Instantly share code, notes, and snippets.

@quonic
Last active June 13, 2017 20:18
Show Gist options
  • Select an option

  • Save quonic/e1589852ba6a4a72842b225cbc2eebeb to your computer and use it in GitHub Desktop.

Select an option

Save quonic/e1589852ba6a4a72842b225cbc2eebeb to your computer and use it in GitHub Desktop.
Add-Type -assembly "Microsoft.Office.Interop.Outlook"
$Outlook = New-Object -comobject Outlook.Application
$namespace = $Outlook.GetNameSpace("MAPI")
$i = 0
$j = 0
$topfolder = ""
$inbox = ""
$namespace.Folders | ForEach-Object {
$i++
if($_.Name -like 'mailbox@example.com'){
$topfolder = $namespace.Folders.Item($i)
#$namespace.Folders.Item($i)
$topfolder.Folders | ForEach-Object {
$j++
if($_.Name -like 'Inbox'){
$inbox = $topfolder.Folders.Item($j)
}
}
}
}
$topfolder.Name
$inbox.Items.Count
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment