title: Extract Zipped file from Outlook mail
body: <p>I'm trying to extract an zip file from my Outlook mail. </p>
  
  <p>Below is my script but its throwing an error object variable or with block variable not set.</p>
  
  <p>On </p>
  
  <pre><code>oApp.NameSpace((FileNameFolder)).CopyHere oApp.NameSpace((Atchmt.FileName)).Items
  </code></pre>
  
  <p>How I fix it. </p>
  
  <pre><code>Sub Unzip()
  Dim ns As NameSpace
  Dim Inbox As MAPIFolder
  Dim SubFolder As MAPIFolder
  Dim Atchmt As Attachment
  Dim FileName As String
  Dim msg As Outlook.MailItem
  Dim FileNameFolder As String
  Dim FSO As Object               'variables for unzipping
  Dim oApp As Object
  
  Set ns = GetNamespace("MAPI")
  Set Inbox = ns.GetDefaultFolder(olFolderInbox)
  Set SubFolder = Inbox.Folders("TEST")
  
  For Each msg In SubFolder.Items
     If msg.UnRead = True Then
          If LCase(msg.Subject) Like "*motor*" Then
              For Each Atchmt In msg.Attachments
                  If (Right(Atchmt.FileName, 3) = "zip") Then
                  MsgBox "1"
                          FileNameFolder = "C:\Users\xxxx\Documents\test\"
                          Set oApp = CreateObject("Shell.Application")
                          oApp.NameSpace((FileNameFolder)).CopyHere oApp.NameSpace((Atchmt.FileName)).Items
  
                  End If
              Next
          End If
      End If
  Next
  End Sub
  </code></pre>