我試圖通過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