title: VBA - Outlook Not Removing Attachments
body: <p>I am writing a macro that should remove attachments. From my debugging sessions, it appears as if it should work. The breakpoint is hit and it recognizes the message object:</p>
  
  <p><a href="https://i.stack.imgur.com/xe6d4.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xe6d4.jpg" alt="enter image description here"></a></p>
  
  <p>I know this sounds a bit silly, but, oddly enough, it seems to work if I set a breakpoint, and open the expression/watch, but not otherwise.</p>
  
  <p>I have been struggling with this for quite some time; I would appreciate any guidance.</p>
  
  <pre><code>Private Sub Application_NewMailEx(ByVal EntryIDCollection As String)
  
   Dim header As String
   Dim objNewMail As Outlook.MailItem
  Dim Item As Object
  Dim count As Integer
  
  
      Dim objInbox As Outlook.Folder
      Set objInbox = Outlook.Session.GetDefaultFolder(olFolderInbox)
  
      Dim entryIDs
      entryIDs = Split(EntryIDCollection, ",")
      Dim i As Integer
  
      For i = 0 To UBound(entryIDs)
          Set objNewMail = Application.Session.GetItemFromID(entryIDs(i))
                  If objNewMail.Attachments.count &gt; 0 Then
                      header = GetHeader(objNewMail)
                  If DoesIPMatch(header) &lt;&gt; True Then
                     DeleteMessage (objNewMail)
                  ElseIf IsAttachmentPDF(objNewMail) &lt;&gt; True Then
                       For count = 1 To objNewMail.Attachments.count
                         objNewMail.Attachments.Remove (count)
                      Next
                  End If
              End If
      Next
  
  End Sub
  </code></pre>