我试图通过PowerShell来获得与下面的代码共享日历的日历项目:PowerShell的COM对象
$outlook = new-object -ComObject Outlook.application
$session = $outlook.Session
$session.Logon("Outlook")
$namespace = $outlook.GetNamespace("MAPI")
$recipient = $namespace.CreateRecipient("John Smith")
$theirCalendar = $namespace.GetSharedDefaultFolder($recipient, "olFolderCalendar")
,但我得到一个类型不匹配错误:
Cannot convert argument "0", with value: "System.__ComObject", for "GetSharedDefaultFolder" to type "Microsoft.Office.I nterop.Outlook.Recipient": "Cannot convert the "System.__ComObject" value of type "System.__ComObject#{00063045-0000-00 00-c000-000000000046}" to type "Microsoft.Office.Interop.Outlook.Recipient"." At line:1 char:34 + $namespace.GetSharedDefaultFolder <<<< ($recipient, "olFolderCalendar") + CategoryInfo : NotSpecified: (:) [], MethodException + FullyQualifiedErrorId : MethodArgumentConversionInvalidCastArgument
我已经试图直接将$收件人转换为Microsoft.Office.Interop.Outlook.Recipient
,这不起作用,并且我也尝试了invoke-method()
程序,这里详细记录了这里:http://www.mcleod.co.uk/scotty/powershell/COMinterop.htm
看来后者应该可以工作,但它似乎没有关于GetSharedDefaultFolder()
要求的多个参数的规定。
与多个smtp和Exchange帐户一起使用时Outlook有什么用处? – Kiquenet 2017-04-12 13:23:32