title: Filter Email Attachments Files by Type
body: <p>I have a script which sends a notification when no attachment was found on the email. Is it possible to check the file type of the attachment and send a notification if the file type is not the one needed.</p>
  
  <p>Got the code like this. </p>
  
  <pre><code>    Option Explicit
          Public Sub CheckAttachment(Item As Outlook.MailItem)
              Dim olInspector As Outlook.Inspector
              Dim olDocument As Outlook.DocumentItem
              Dim olSelection As Outlook.Selection
              Dim objAtt As Outlook.Attachment
              Dim ft As FileTypes
              Dim olReply As MailItem
              Dim FileExtension As String
              FileExtension = "jpeg, jpg, tiff, pdf"
  
              '// Check for attachment
              If Item.Attachments.Count &gt; 1 Then
              GoTo CheckFileType1
                  End If
  
  
  
          CheckFileType1:
              If Item.Attachments(Item.Attachments, ".tiff") Then
              GoTo CheckFileType2
              End If
  
          CheckFileType2:
              If Item.Attachments(Item.Attachments, ".jpeg") Then
              GoTo CheckFileType3
              End If
  
          CheckFileType3:
              If Item.Attachments(Item.Attachments, ".pdf") Then
              GoTo SendMail
              Else
              Exit Sub
              End If
  
          SendMail:
              Set olReply = Item.Reply '// Reply if no attachment found
              olReply.Body = "No attachment was found. Re-send the email and ensure that the needed file is attached." &amp; vbCrLf &amp; vbCrLf &amp; vbCrLf &amp; vbCrLf &amp; vbCrLf &amp; "This is a system generated message. No need to reply. Thank you."
              olReply.Send
  
              Set olInspector = Nothing
              Set olDocument = Nothing
              Set olSelection = Nothing
  
  
          End Sub
  </code></pre>