title: Save Outlook Attachment to Folder on PC using Excel VBA
body: <p>I am trying to save attachments from a sub-folder in Outlook to a folder on my C drive using Excel VBA.</p>
  
  <p>For example, in my inbox folder I have a sub-folder called 'data' and in this folder there are emails with different excel attachments of different data but with the same formatting and the same attachment name but with an updated date (Eg: "Attachment name + 28 March").</p>
  
  <p>These emails are sent daily. I want all attachments, not already saved, saved to a folder on my C drive and then open each attachment to extract the relevant data to Excel.</p>
  
  <p>I am able to extract the relevant data once the files are in my C drive but I am unable to set up a path from my Excel to Outlook without Outlook VBA (which I don't want to do).</p>
  
  <p>This is what I have so far: (the comments are for my benefit because I am new to this)</p>
  
  <pre><code>Sub attachmentsave()
  
  Dim olook As Outlook.Application
  Dim omailitem As Outlook.mailitem
  'whenever dealing with folders we need to define outlook.namespace This is a class that opens the gate for me to access all outlook folders
  Dim onamespace As Outlook.Namespace
  
  Dim fol As Outlook.Folder 'we need to tell vba where we have out emails with attachments stored
  Dim atmt As Outlook.Attachment '.attachment is a class that will help us deal with emails that have attachments
  
  Set olook = New Outlook.Application
  Set omailitem = olook.CreateItem(olmailitem)
  
  'messaging application protocol interface
  Set onamespace = olook.GetNameSpace("MAPI")
  Set fol = onamespace.GetDefaultFolder(olFolderInbox)
  
  For Each omailitem In fol.items
      For Each atmt In omailitem.attachments
  
          atmt.SaveAsFile "C:/" &amp; atmt.FileName
          'all attachments in inbox should be save in C drive
  
      Next
  
  Next
  
  End Sub
  </code></pre>