title: Extract attachments from saved .msg files using VBA
body: <p>I am trying to extract attached Excel spreadsheets from saved Outlook messages. The messages have been saved into a shared folder as .msg files.</p>
  
  <p>I am struggling to get VBA to recognise the messages as files.</p>
  
  <p>I am trying to get the message details in the code below as a proof of concept.</p>
  
  <p>Once I have this working I can work on looping through the files and dealing with the attachments.</p>
  
  <p>I have found code on this site for extracting attachments from emails still in Outlook but I do not have access to the Outlook folders and the original messages have been deleted.</p>
  
  <pre><code>Sub ExtractExcel()
  Dim aExcel As Outlook.Attachment
  Dim stFilePath As String
  Dim stFileName As String
  Dim stAttName As String
  Dim stSaveFolder As String
  Dim oEmail As Outlook.MailItem
  
  '~~&gt; Outlook Variables for email
  Dim eSender As String, dtRecvd As String, dtSent As String
  Dim sSubj As String, sMsg As String
  
  stFilePath = "Y:\Purchasing\The Team\User Name\Supply Chain Admin - Outlook\New-Revised Orders\FW  Mail Order Daffodil.msg"
  stSaveFolder = "C:\Projects\SOTD\PO_Excel"
  
  Debug.Print stFilePath
  Debug.Print stSaveFolder
  
  oEmail = stFilePath
  
  With oEmail 
      eSender = oEmail.SenderEmailAddress
      dtRecvd = oEmail.ReceivedTime
      dtSent = oEmail.CreationTime
      sSubj = oEmail.Subject
      sMsg = oEmail.Body
  
      Debug.Print eSender
      Debug.Print dtRecvd
      Debug.Print dtSent
      Debug.Print sSubj
      Debug.Print sMsg
  End With
  
  End Sub
  </code></pre>
  
  <p>I'm using Excel VBA as I am familiar with it but am happy to have any alternative strategies suggested.</p>