This code is meant to download an Outlook email attachment based on a check if the mailitem was received past the date specified by the user in cell C6.
Stepping through the code reveals the code reads the following line of code as if it is checking the mail item against itself (i.e. mailitem received on 01/01/01 code says if mailitem=01/01/01 then) the mailitem always meets this check.
If MailItem.ReceivedTime >ThisWorkbook.Worksheets("Email_Info").Range("C6").Value Then
Option Explicit
Sub Download_Outlook_Attachemtns()
Dim olAPP As Outlook.Application
Dim olNS As Outlook.Namespace
Dim olFolder As Outlook.MAPIFolder
Dim olItem As Object
Dim MailItem As Outlook.MailItem
Dim olAtt As Outlook.Attachment
Set olAPP = New Outlook.Application
Set olNS = olAPP.getnamespace("MAPI")
'single folder link to hidden sheet folders([admin].[Mailbox].text)
Set olFolder = olNS.Folders("John@work.com")
Set olFolder = olFolder.Folders("Inbox")
Set olFolder = olFolder.Folders("Work Requests")
For Each olItem In olFolder.Items
If olItem.Class = olMail Then
Set MailItem = olItem
For Each olAtt In MailItem.Attachments
If MailItem.ReceivedTime > ThisWorkbook.Worksheets("Email_Info").Range("C6").Value Then
olAtt.SaveAsFile ("C:\Users\John Smith\Desktop\WOR Email Download") & olAtt.Filename
End If
Next olAtt
End If
Next olItem
End Sub