根据 the documentation ,我应该能够在我的 Outlook 规则中指定一个条件,该条件基于发件人地址的部分字符串匹配,方法是在 TextRuleCondition.Text
中指定要匹配的文本,条件为 olConditionSenderAddress
:
但是,我无法在 Rule.Conditions
中找到合适的属性来设置目的。如果我枚举新创建的规则的条件,则没有 TextRuleCondition
类型的现有条件具有 ConditionType == olConditionSenderAddress
。具有正确 ConditionType
的唯一条件是 AddressRuleCondition
,它没有 Text
属性。
如何以编程方式在 Outlook 2010 规则中指定发件人地址包含特定字符串的条件?
最佳答案
您可以使用 Conditions.SenderAddress
规则条件并使用其地址属性,如下所示:
Dim colRules As Outlook.Rules
Dim oRule As Outlook.Rule
Dim oAddressRuleCondition As Outlook.AddressRuleCondition
Set colRules = Application.Session.DefaultStore.GetRules()
Set oRule = colRules.Create("Sender Rule", olRuleReceive)
Set oAddressRuleCondition = oRule.Conditions.SenderAddress
With oAddressRuleCondition
.Enabled = True
.Address = Array("example")
End With
.....
colRules.Save
关于c# - 根据发件人地址中的单词指定 Outlook 规则条件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17606592/