I'm working on a VBA script for Outlook, that sorts emails so only emails with PDF files are in the inbox.
I have thanks to a previous answered question in Stackoverflow gotten this VBA script working and doing the tasks.
Sub MoveMail(Item As Outlook.MailItem)
If Item.Attachments.Count > 0 Then
Dim attCount As Long
Dim strFile As String
Dim sFileType As String
attCount = Item.Attachments.Count
For i = attCount To 1 Step -1
strFile = Item.Attachments.Item(i).FileName
sFileType = LCase$(Right$(strFile, 4))
Select Case sFileType
Case ".txt", ".doc", "docx", ".xls", "xlsx"
' do something if the file types are found
' this code moves the message
Item.Move (Session.GetDefaultFolder(olFolderInbox).Folders("Reply"))
' stop checking if a match is found and exit sub
GoTo endsub
End Select
Next i
End If
endsub:
Set Item = Nothing
End Sub
I need to also sort emails without attachment.
How do I check emails if the attachment is other then PDF or doesn't have any attachment then move it to a folder in Outlook called Reply?