是否可以从 .msg 文件中提取收件人电子邮件地址?

Is it possible to extract recipient email address from a .msg file?

为了从一批 .msg 文件中编译收件人列表,我正在尝试使用 powershell 来实现。我可以获取收件人姓名,但不能获取他们的电子邮件。他们的地址条目显示为 System._ComObject

对我做错了什么以及如何解决这个问题有什么建议吗?谢谢。

$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()

感谢 Palle Due:

$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()

关于特殊的属性值;这里有一个有用的列表: