【发布时间】:2016-09-28 01:34:40
【问题描述】:
我一直在为 Powershell 处理 Outlook 对象。我想创建 Outlook 规则并让它工作。暂时搁置了这个项目。 当我把它捡起来时,我无法创建 Outlook 规则。请注意,我没有更改代码中的任何内容。
代码生成 Outlook 规则
$rules = $ol.Session.DefaultStore.GetRules()
$rule = $rules.Create("spamfilter",[Microsoft.Office.Interop.Outlook.OlRule Type]::olRuleReceive)
$condition = $rule.Conditions.SenderAddress
$condition.Enabled = $true
$condition.Address = @("<sender>")
$action = $rule.Actions.MoveToFolder
$action.Enabled = $true
[Microsoft.Office.Interop.Outlook._MoveOrCopyRuleAction].InvokeMember("Folder",[System.Reflection.BindingFlags]::SetProperty,$null,$action,$junk)
$rules.Save()
错误
使用“5”参数调用“InvokeMember”的异常:“未找到成员。(来自 HRESULT 的异常:0x80020003 (DISP_E_MEMBERNOTFOUND))” 在 line:22 char:5
- [Microsoft.Office.Interop.Outlook._MoveOrCopyRuleAction].InvokeMember("Folde ...
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- CategoryInfo : NotSpecified: (:) [], MethodInvocationException
- FullyQualifiedErrorId : COMException
有人请帮助我。似乎是什么问题?我迷路了,谢谢。
【问题讨论】:
-
已经在前面的代码中定义了
标签: powershell outlook powershell-2.0 outlook-2010