PowerShell/Scripts/list-outlook-inbox.ps1

24 lines
581 B
PowerShell
Raw Normal View History

2022-04-11 11:03:35 +02:00
<#
.SYNOPSIS
Lists Outlook's Inbox
.DESCRIPTION
This PowerShell script lists the emails in the inbox of Outlook.
.EXAMPLE
PS> ./list-outlook-inbox
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz | License: CC0
#>
try {
$Outlook = New-Object -com Outlook.application
$MAPI = $Outlook.GetNameSpace("MAPI")
$Inbox = $MAPI.GetDefaultFolder(6) # 6 = olFolderInbox
$Inbox.items | Select Received,Subject | Format-Table -AutoSize
exit 0 # success
} catch {
2022-04-13 12:06:32 +02:00
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
2022-04-11 11:03:35 +02:00
exit 1
}