PowerShell/scripts/list-outlook-inbox.ps1

24 lines
585 B
PowerShell
Raw Normal View History

2023-10-31 12:33:36 +01:00
<#
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
2023-08-06 21:35:36 +02:00
PS> ./list-outlook-inbox.ps1
2022-04-11 11:03:35 +02:00
.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
}