title: Open Outlook Mail .msg file using VBA from Excel
body: <p>I'm trying to <strong>open .msg files from a specified directory using VBA</strong> but I keep getting a runtime error.</p>
  <p>The code i have:</p>
  <pre><code>Sub bla()
      Dim objOL As Object
      Dim Msg As Object
      Set objOL = CreateObject(&quot;Outlook.Application&quot;)
      inPath = &quot;C:\Users\SiliconPlus\Desktop\Si+ Contact Lists\Contact_Si+&quot;
      thisFile = Dir(inPath &amp; &quot;\*.msg&quot;)
      Set Msg = objOL.CreateItemFromTemplate(thisFile)
      ' now use msg to get at the email parts
      MsgBox Msg.Subject
      Set objOL = Nothing
      Set Msg = Nothing
  End Sub
  </code></pre>
  <p>Here is the runtime error:</p>
  <blockquote>
  <p>Run-time error '-2147287038 (80030002)':</p>
  <p>Cannot open file: AUTO Andy Low Yong Cheng is out of the office (returning 22 09 2014).msg.</p>
  <p>The file may not exist, you may not have permission to open it, or it may be open in another program. Right-click the folder that contains the file, and then click properties to check your permissions for the folder.</p>
  </blockquote>