如何使用powershell获取outlook 2003收件箱
我使用下面的代码使用Powershell获取outlook收件箱信息如何使用powershell获取outlook 2003收件箱,powershell,outlook,powershell-2.0,outlook-2003,Powershell,Outlook,Powershell 2.0,Outlook 2003,我使用下面的代码使用Powershell获取outlook收件箱信息 Function Get-OutlookInBox { Add-type -assembly "Microsoft.Office.Interop.Outlook" | out-null $olFolders = "Microsoft.Office.Interop.Outlook.olDefaultFolders" -as [type] $outlook = new-object -comobject out
Function Get-OutlookInBox
{
Add-type -assembly "Microsoft.Office.Interop.Outlook" | out-null
$olFolders = "Microsoft.Office.Interop.Outlook.olDefaultFolders" -as [type]
$outlook = new-object -comobject outlook.application
$namespace = $outlook.GetNameSpace("MAPI")
$folder = $namespace.getDefaultFolder($olFolders::olFolderInBox)
$folder.items |
Select-Object -Property Subject, ReceivedTime, Importance, SenderName
}
$inbox=Get-OutlookInBox
$inbox | Group-Object -Property senderName -NoElement | Sort-Object count
这在Outlook2007的Win7中工作得非常好。然而,Outlook 2003 XP给出了以下错误
Add-Type : Could not load file or assembly 'Microsoft.Office.Interop.Outlook, Version=12.0.0.0, Culture=neutral, PublicKey
Token=71e9bce111e9429c' or one of its dependencies. The system cannot find the file specified.
Outlook 2003的第一个版本是11.0版,它错误地显示了12.0.0.0版。
是否还有其他需要执行的操作。尝试明确指定所需互操作程序集的版本:
Add-Type -AssemblyName ('Microsoft.Office.Interop.Outlook, Version=11.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c')
检查您的GAC的内容,看看您那里有什么版本的互操作程序集。谢谢,我的GAC中没有安装11.0.0.0版本,现在可以正常工作了。