建立 Outlook VBA 以轉送主旨行中包含特定單字的電子郵件

建立 Outlook VBA 以轉送主旨行中包含特定單字的電子郵件

您好,我想在 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

相關內容