我想用VBA创建规则,而不是在规则中运行脚本,该规则将为来自特定域的电子邮件添加类别(红色)接收。我可以指出接收和特定域的一部分,但我正在努力使用正确的类别VBA语法。类别的颜色是红色,类别的名称是“SPAM”。这是我最近的尝试:使用VBA创建规则,在收到邮件时将类别添加到电子邮件
Dim oRuleNew As Outlook.Rule
Dim oCategoryRuleConditionSpam As Outlook.CategoryRuleCondition
Set oCategoryRuleConditionSpam = oRuleNew.Conditions.Category
With oCategoryRuleConditionSpam
.Enabled = True
.Categories = "SPAM"
End With
基本上我找不出如何将正确的值分配给.Categories ..任何帮助将非常感激。
也试过: .Categories.Add( “SPAM”)
其实,或许下面是更适合的任务:
Dim oRuleNew As Outlook.Rule
Dim oCategoryRuleActionSpam As Outlook.RuleAction
Set oCategoryRuleActionSpam = oRuleNew.Action.AssignToCategory
With oCategoryRuleActionSpam
.Enabled = True
.Categories = "SPAM"
End With
但现在我收到错误13 :(
找到了!
Dim oRuleNew As Outlook.Rule
Dim oCategoryRuleActionSpam As Outlook.RuleAction
Dim aCat(0) As String
aCat(0) = "SPAM"
Set oCategoryRuleActionSpam = oRuleNew.Action.AssignToCategory
With oCategoryRuleActionSpam
.Enabled = True
.Categories = aCat
End With
嗨尤金,再次感谢您的帮助。不幸的是,它返回错误438 :( – clippertm 2015-02-25 02:31:49
也名字已经存在(垃圾邮件,红色) – clippertm 2015-02-25 02:38:16
它看起来像邮件已经标记了类别,我是对吗? – 2015-02-25 08:08:22