![创建一个 Outlook VBA 来转发主题行中包含特定单词的电子邮件](https://linux22.com/image/1476400/%E5%88%9B%E5%BB%BA%E4%B8%80%E4%B8%AA%20Outlook%20VBA%20%E6%9D%A5%E8%BD%AC%E5%8F%91%E4%B8%BB%E9%A2%98%E8%A1%8C%E4%B8%AD%E5%8C%85%E5%90%AB%E7%89%B9%E5%AE%9A%E5%8D%95%E8%AF%8D%E7%9A%84%E7%94%B5%E5%AD%90%E9%82%AE%E4%BB%B6.png)
您好,我想在 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