创建 MSOutlook Com-Object 并使其可见
Create MSOutlook Com-Object and make it visible
我想启动 MS Outlook 以实现自动化并使其可见。我正在输入命令:
(new-object -com Outlook.Application).GetNamespace("MAPI").GetDefaultFolder("olFolderInbox").GetExplorer().Display()
抛出错误:
Exception setting "GetDefaultFolder": Cannot convert the "olFolderInbox" value of type "string" to type "Object".
At line:1 char:1
+ (new-object -com Outlook.Application).GetNamespace("MAPI").GetDefault ...
这也行不通:
$Outlook = New-Object -ComObject Outlook.Application
$Outlook.visible = $True
剧透!这有效:
(new-object -com Outlook.Application).GetNamespace("MAPI").GetDefaultFolder([Microsoft.Office.Interop.Outlook.OlDefaultFolders]::olFolderInbox).GetExplorer().Display()
NameSpace.GetDefaultFolder method takes the type of default folder to return represented by the OlDefaultFolders枚举(数值)。
我想启动 MS Outlook 以实现自动化并使其可见。我正在输入命令:
(new-object -com Outlook.Application).GetNamespace("MAPI").GetDefaultFolder("olFolderInbox").GetExplorer().Display()
抛出错误:
Exception setting "GetDefaultFolder": Cannot convert the "olFolderInbox" value of type "string" to type "Object".
At line:1 char:1
+ (new-object -com Outlook.Application).GetNamespace("MAPI").GetDefault ...
这也行不通:
$Outlook = New-Object -ComObject Outlook.Application
$Outlook.visible = $True
剧透!这有效:
(new-object -com Outlook.Application).GetNamespace("MAPI").GetDefaultFolder([Microsoft.Office.Interop.Outlook.OlDefaultFolders]::olFolderInbox).GetExplorer().Display()
NameSpace.GetDefaultFolder method takes the type of default folder to return represented by the OlDefaultFolders枚举(数值)。