title: Permission error running "Application.CreateItemFromTemplate" method on an EML file
body: <p>I'm trying to run a macro that copies EML files into my inbox.</p>
  <p>When I get to the <code>Application.CreateItemFromTemplate</code> line to apply it to an EML file I get a runtime error:</p>
  <blockquote>
  <p>We can't open [filename.path]. It's possible the file is already open, or you don't have permission to open it.</p>
  </blockquote>
  <p>I tried running Outlook as ADMIN. Also tried the <code>Session.OpenSharedItem</code> method. I'm using Outlook for Microsoft 365 MSO.</p>
  <p>Full code:</p>
  <pre class="lang-vb prettyprint-override"><code>Sub ImportMessagesToOutlookFolder()
      Dim fso As Scripting.FileSystemObject
      Dim SourceFolder As Scripting.Folder
      Dim SourceFolderName As String
      Dim FileItem As Scripting.File
      Dim strFile, strFileType As String
      Dim oMsg As Object
      Dim objNS As NameSpace
      Dim copiedMsg As MailItem
      Dim Savefolder As Outlook.Folder
      
      Set fso = New Scripting.FileSystemObject 'Source folder
  
      'Ask for folder with items to import
       SourceFolderName = BrowseForFolder(&quot;My Computer&quot;)
       Set SourceFolder = fso.GetFolder(SourceFolderName)
      
     'Set the Outlook folder name
       Set objNS = Application.GetNamespace(&quot;MAPI&quot;)
       Set Savefolder = objNS.PickFolder
  
      For Each FileItem In SourceFolder.Files
       
          'Set oMsg = FileItem
          Set oMsg = Outlook.Application.CreateItemFromTemplate(FileItem.Path)
          
          'On Error Resume Next
      
          Set copiedMsg = oMsg.Copy
              
              copiedMsg.Move Savefolder
      
          Set copiedMsg = Nothing
          Debug.Print FileItem.Name &amp; &quot; &quot; &amp; FileItem.DateCreated
          
          oMsg.Delete
          Set oMsg = Nothing
          'FileItem.Delete
      
      Next FileItem
  
      Set FileItem = Nothing
      Set SourceFolder = Nothing
      Set fso = Nothing
        
  End Sub 
  </code></pre>