Hi everyone,
I have a list of ID numbers in excel and when we have sent an email it gets marked with the sent date and when we get the reply we mark it again. Due to user error some get missed so I've to get excel to search through outlook Sent box to see if an email had been sent.
I now need to do this for the Inbox however there are many subfolders that the email could be hiding in and i only know how to search the main inbox, could anybody help me in getting it to also go through every subfolder?
Also is there a way to make this quicker as it did take 3 days to complete!!! I came across maybe using "items.Restrict" not sure if that would work for what i need it for and if it would be quicker - https://docs.microsoft.com/en-us/off...items.restrict I did try however i couldn't understand/get it to work.
The below code goes through outlook Sent box to find the emails that have been sent to change it to inbox i would change "olFolderSentMail" to "olFolderInbox" but that only looks in the inbox not sub folders.
Sub CheckSentEmail()
Dim OutlookMail As Variant
Dim OutlookItems
Dim subject As String
Set OutlookItems = CreateObject("Outlook.Application").GetNamespace("MAPI").GetDefaultFolder(olFolderSentMail).Items
For Each cell In Sheets("Tracker").Range("B2:B11891")
For Each OutlookMail In OutlookItems
If (InStr(1, OutlookMail.subject, cell, vbTextCompare) > 0) Then
If subject <> "" Then subject = subject & " | "
subject = subject & OutlookMail & " - " & OutlookMail.ReceivedTime
cell.Offset(0, 16).Interior.ColorIndex = 4
End If
Next
cell.Offset(0, 44) = subject
subject = ""
Next
MsgBox "Finished at " & Time
End Sub
Any help would be greatly appreciated especially if it makes the process quicker seeing as i was hoping to complete it by Monday
Thank you for your help
Martin
Bookmarks