title: Open "x" file triggered by incoming email with subject containing "x"
body: <p>I'm trying to open X file (.bat) when an email with subject X arrives. The sender is always the same.</p>
  
  <p>Example: email received from Security with the following subject "balcony alert"; the "balcony.bat" file should open automatically.</p>
  
  <p>I tried to edit the following but it needs to be expanded more, and I have an error in compiling the first line.</p>
  
  <pre><code>Private WithEvents Items As Outlook.Items
  Private Sub Application_Startup()
    Dim olApp As Outlook.Application
    Dim objNS As Outlook.NameSpace
    Set olApp = Outlook.Application
    Set objNS = olApp.GetNamespace("MAPI")
  
    ' default local Inbox
    Set Items = objNS.GetDefaultFolder(olFolderInbox).Items
  End Sub
  
  Private Sub Items_ItemAdd(ByVal item As Object)
  
    On Error GoTo ErrorHandler
    Dim Msg As Outlook.MailItem
  
    If TypeName(item) = "Security" Then
      Set Msg = item
  
      ' If Msg.Subject = "specific subject" Then
  
      Call Shell("cmd.exe /C /K " &amp; "ChDir f:\" &amp; Msg.Subject &amp; ".bat", vbNormalFocus)
  
    End If
  End If
  
  ProgramExit:
    Exit Sub
  ErrorHandler:
    MsgBox Err.Number &amp; " - " &amp; Err.Description
    Resume ProgramExit
  End Sub
  </code></pre>