
こんにちは。件名に 3 つの特定の単語が任意の順序で含まれるルールまたは VBA を Outlook で作成したいと考えています。たとえば、「バッジ、ユーザー、モペット」を検索したいのです。
件名: バッジとモペットのユーザー。
件名にこの 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