![件名に特定の単語が含まれるメールを転送するための Outlook VBA を作成する](https://rvso.com/image/1476400/%E4%BB%B6%E5%90%8D%E3%81%AB%E7%89%B9%E5%AE%9A%E3%81%AE%E5%8D%98%E8%AA%9E%E3%81%8C%E5%90%AB%E3%81%BE%E3%82%8C%E3%82%8B%E3%83%A1%E3%83%BC%E3%83%AB%E3%82%92%E8%BB%A2%E9%80%81%E3%81%99%E3%82%8B%E3%81%9F%E3%82%81%E3%81%AE%20Outlook%20VBA%20%E3%82%92%E4%BD%9C%E6%88%90%E3%81%99%E3%82%8B.png)
こんにちは。件名に 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