Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Powershell 是否可以从.msg文件中提取收件人电子邮件地址?_Powershell_Outlook_Powershell 4.0 - Fatal编程技术网

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

Powershell 是否可以从.msg文件中提取收件人电子邮件地址?,powershell,outlook,powershell-4.0,Powershell,Outlook,Powershell 4.0,为了从一批.msg文件中编译收件人列表,我尝试使用powershell实现这一点。我可以获取收件人的姓名,但不能获取他们的电子邮件。他们的地址条目显示为System.\u ComObject 对我做错了什么以及如何解决这个问题有什么建议吗?多谢各位 $outlook = New-Object -ComObject Outlook.Application $namespace = $outlook.GetNameSpace("MAPI") Get-ChildItem $msgPath -Filt

为了从一批.msg文件中编译收件人列表,我尝试使用powershell实现这一点。我可以获取收件人的姓名,但不能获取他们的电子邮件。他们的地址条目显示为System.\u 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到期:

关于特殊的财产价值;这里有一个有用的列表:

感谢Palle Due:


关于特殊的财产价值;这里有一个有用的列表:

您调用此属性正确吗?编辑后,我可以访问该属性,但没有输出任何内容@Muffinmani建议获取Outlook Spy并检查特定邮件以查看SMTP地址的位置。不幸的是,电子邮件不总是在地址中,也不总是电子邮件地址。有时它是exchange邮箱字符串,有时它位于某个模糊的MAPI属性中。对于专为电子邮件构建的应用程序,您可能会认为访问电子邮件地址是最直接的操作。@Muffindman如果我只吐出$recipient,我会收到一个exchange邮箱字符串。无法解析该字符串吗?可能通过active directory搜索?您调用此属性正确吗?编辑后,我可以访问该属性,但没有输出任何内容@Muffinmani建议获取Outlook Spy并检查特定邮件以查看SMTP地址的位置。不幸的是,电子邮件不总是在地址中,也不总是电子邮件地址。有时它是exchange邮箱字符串,有时它位于某个模糊的MAPI属性中。对于专为电子邮件构建的应用程序,您可能会认为访问电子邮件地址是最直接的操作。@Muffindman如果我只吐出$recipient,我会收到一个exchange邮箱字符串。无法解析该字符串吗?可能是通过active directory搜索?(投票关闭,因为链接的答案给出了您想要的答案;但我已经在您的代码中包含了Palle的解决方案,以帮助您)这太棒了!非常感谢你@JohnLBevan(投票结束,因为链接的答案给出了您想要的;但我已经在您的代码中包含了Palle的解决方案,以便在此期间提供帮助)这太棒了!非常感谢你@约翰比万
$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()