title: Outlook rule to run a script which filters body source
body: <p>I saw that we could use the MailItem.HTMLBody element but I did not understand how to do it.</p>
  <p>It is simply a matter of detecting the term &quot;email &lt;o: p&gt;&quot; in the source of the received email. Once transmitted, I want to move the email to a folder already created, or to be created by the script.</p>
  <pre class="lang-vb prettyprint-override"><code>Sub filter(Item As Outlook.MailItem)
      Dim source As String
      Dim ns As Outlook.NameSpace
      Dim MailDest As Outlook.Folder
      Set ns = Application.GetNamespace(&quot;MAPI&quot;)
      source = Item.HTMLBody
      If InStr(source, &quot;email&lt;o:p&gt;&quot;) &gt; 0 Then
          Set MailDest = ns.Folders(&quot;Personal Folders&quot;).Folders(&quot;test&quot;)
          Item.Move MailDest
      End If
  </code></pre>
  <p>If I remove &quot;Item&quot;, do I have to use ThisOutlookSession module?</p>
  <p>And then, what are the precise steps to get it triggered?</p>
  <p>When I create a rule that detects the object I don't have &quot;run macro&quot; in the list.</p>
  <p>I need to create a rule &quot;If email from hello@me.com&quot; that triggers this VBA but I can't find that in Outlook rules manager.</p>