我正在使用vba代码从输入文件中的文本创建规则。规则中我需要的规则条件之一是检查收到的电子邮件的邮件标题,并根据邮件标题内容将电子邮件移动到特定文件夹。
我试过用这个。文本属性无效。
我在谷歌上搜索了一些问题,想找到一个解决方案,但什么都没找到。
我正在使用vba代码创建300多条规则,其中许多规则需要消息头测试。
任何帮助都将不胜感激
罗恩
编辑:当我给oRule分配一个文本字符串时,我遇到了同样的错误。条件主题此代码中的文本。
编辑:我刚刚意识到我没有提到错误——这是“运行时错误'13'-类型不匹配”
我尝试过在字段中使用String和Variant,得到了相同的消息。
我的代码如下:
Dim strMessageHeader作为变体
Do While Not EOF(1)
Input #1, StrRuleName, strCond, strFrom, strSubject, strSentTo, strMessageHeader, strSendersAddress, strMoveTo, strSetCategory
' Create the rule
Set oRule = colRules.Create(StrRuleName, olRuleReceive)
' What is the condition?
Select Case strCond
Case olConditionFrom ' 1 - Condition is "from"
Set oFromCondition = oRule.Conditions.From
With oFromCondition
.Enabled = True
.Recipients.Add (strFrom)
.Recipients.ResolveAll
End With
Case olConditionSubject ' 2 - Condition is text "in the subject"
Set oSubjectCondition = oRule.Conditions.Subject
With oSubjectCondition
.Enabled = True
.Text = strSubject
End With
Case olConditionSentTo ' 12 - Condition is "sent to a specific email"
Set oSentToCond = oRule.Conditions.SentTo
With oSentToCond
.Enabled = True
.Recipients.Add (strSentTo)
End With
Case olConditionMessageHeader ' 15 - Condition is text "in the message header"
Set oMsgHdrCond = oRule.Conditions.MessageHeader
With oMsgHdrCond
.Text = strMessageHeader
End With