Assumptions:
1) The sheet containing the data is the active sheet.
2) Column A contains "From", and Column B contains "Subject"
Notes:
1) For each name in Column A, the macro searches and flags all emails with the same name and corresponding subject.
2) The search in matching both the name and subject is case-sensitive.
3) A reference needs to be set by selecting 'Tools > References > Microsoft Outlook xx.x Object Library'.
Code:
Option Explicit
Sub Promote()
Dim OL As Outlook.Application
Dim NS As Outlook.Namespace
Dim MItems As Outlook.Items
Dim MItem As Outlook.MailItem
Dim strName As String
Dim strSubject As String
Dim i As Long
Dim LastRow As Long
Set OL = CreateObject("Outlook.Application")
Set NS = OL.GetNamespace("MAPI")
Set MItems = NS.GetDefaultFolder(olFolderInbox).Items
LastRow = Cells(Rows.Count, "A").End(xlUp).Row
For i = 2 To LastRow
strName = Cells(i, "A").Value
strSubject = Cells(i, "B").Value
Set MItem = MItems.Find("[From] = " & strName)
While TypeName(MItem) <> "Nothing"
If MItem.Subject = strSubject Then
MItem.FlagIcon = olBlueFlagIcon
MItem.Save
End If
Set MItem = MItems.FindNext
Wend
Next i
End Sub
Bookmarks