您好,我想在 Outlook 中创建一个规则或 VBA,其中主题行包含 3 个特定单词,顺序不限。例如,我想查找“徽章、用户、轻便摩托车”
主题说:徽章和带有轻便摩托车的用户。
如果主题中包含这三个词,那么我希望它将电子邮件转发给某人。
找到了“mark-goldfain”编写的这段代码,我想也许我们可以修改它?虽然我对 VBA 编程一无所知。
Public Sub File_Stock_Incoming_Message(Item As Outlook.MailItem)
' This macro is called from a wizard-built rule, where the
' rule operates on *every* incoming message, and its action
' is to call this macro.
Dim NS As Outlook.NameSpace
Set NS = Application.Session
Dim MoveToFolder As Outlook.MAPIFolder
Set MoveToFolder = NS.Folders("mainboxname").Folders("MsgLog")
Dim sbjstr As String
sbjstr = Item.Subject
If (sbjstr = "Whatever Site Error") Then
Item.Move MoveToFolder
End If
End Sub
答案1
您只需要改变以下条件If
:
instr(item.subject,"word1")>0 And instr(item.subject,"word2")>0 And instr(item.subject,"word3")>0