PowerShell/scripts/list-outlook-sent.ps1

24 lines
599 B
PowerShell
Raw Normal View History

2024-10-01 15:11:03 +02:00
<#
2022-04-11 11:17:45 +02:00
.SYNOPSIS
Lists Outlook's Sent Mails
.DESCRIPTION
This PowerShell script lists the mails in the Sent Mail folder of Outlook.
.EXAMPLE
2023-08-06 21:35:36 +02:00
PS> ./list-outlook-sent.ps1
2022-04-11 11:17:45 +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(5) # 5 = olFolderSentMail
$Inbox.items | Select SentOn,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:17:45 +02:00
exit 1
}