The other day I posted a question on counting attached files to emails in outlook. Had a great answer and the following VBA. So the new problem is it works to good. Its counting everything in the email as an attached file. I been looking to see if others may have had a solution to filter out items that are really not an attachment but have not had any luck. I am again asking here and hope someone can help. I really only need to be counting the attached files as in a DOC, PDF, XLS etc and not all the other items that maybe in the mail such as the signature jpg etc... any help would be great. Thanks in advance.
Sub CountEmails()
Dim objOutlook As Object, objnSpace As Object, objFolder As Object
Dim EmailCount As Integer
Dim AttCount As Integer
Set objOutlook = CreateObject("Outlook.Application")
Set objnSpace = objOutlook.GetNamespace("MAPI")
On Error Resume Next
Set objFolder = objnSpace.Folders("Personal Mail").Folders("inbox")
If Err.Number <> 0 Then
Err.Clear
MsgBox "No such folder."
Exit Sub
End If
EmailCount = objFolder.items.Count
For Each Item In objFolder.items
x = Item.Attachments.Count
AttCount = AttCount + x
Next
MsgBox "Number of emails in the folder: " & EmailCount
MsgBox AttCount & " attachments"
Range("B3").Select
Selection = EmailCount
Range("B4").Select
Selection = AttCount
End Sub
Sub CountEmails()
Dim objOutlook As Object, objnSpace As Object, objFolder As Object
Dim EmailCount As Integer
Dim AttCount As Integer
Set objOutlook = CreateObject("Outlook.Application")
Set objnSpace = objOutlook.GetNamespace("MAPI")
On Error Resume Next
Set objFolder = objnSpace.Folders("Personal Mail").Folders("inbox")
If Err.Number <> 0 Then
Err.Clear
MsgBox "No such folder."
Exit Sub
End If
EmailCount = objFolder.items.Count
For Each Item In objFolder.items
x = Item.Attachments.Count
AttCount = AttCount + x
Next
MsgBox "Number of emails in the folder: " & EmailCount
MsgBox AttCount & " attachments"
Range("B3").Select
Selection = EmailCount
Range("B4").Select
Selection = AttCount
End Sub