In order to compile a list of recipients from a batch of .msg files, I'm trying to achieve this with powershell. I can grab the Recipient name, but not their emails. Their address entry shows as System._ComObject
Any advice to what I'm doing wrong and how I can fix this? Thank you.
$outlook = New-Object -ComObject Outlook.Application
$namespace = $outlook.GetNameSpace("MAPI")
Get-ChildItem $msgPath -Filter *.msg |
ForEach-Object{
$msg = $outlook.Session.OpenSharedItem($_.FullName)
$recipient = $msg.Recipients
$address = $recipient.Address
$recipient
}
$outlook.quit()
Thanks to Palle Due: https://stackoverflow.com/a/47264921/361842
$outlook = New-Object -ComObject Outlook.Application
$namespace = $outlook.GetNameSpace("MAPI")
Get-ChildItem $msgPath -Filter *.msg |
ForEach-Object{
$msg = $outlook.Session.OpenSharedItem($_.FullName)
$msg.Recipients | ForEach-Object{
$_.PropertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x39FE001E")
}
}
$outlook.quit()
Regarding the special property value; there's a helpful list here: https://stackoverflow.com/a/45296809/361842