This code runs on my friend's Excel.
On mine it throws an error on the line Range("C" & i).Value = olMail.To
.
This is the code.
Sub Trial()
Dim olApp As Outlook.Application
Dim olNS As Namespace
Dim Fldr As MAPIFolder
Dim olMail As Object
Dim i As Integer, j As Integer
Set olApp = New Outlook.Application
Set olNS = olApp.GetNamespace("MAPI")
Set Fldr = olNS.GetDefaultFolder(olFolderInbox)
Sheets("Sheet1").Select
i = [Counta(Sheet1!A:A)]
Dim lastMail As String
If i = 1 Then
lastMail = 0
Else
lastMail = Range("B" & i).Value
End If
For Each olMail In Fldr.Items
If olMail.UnRead = True Then
i = i + 1
Range("C" & i).Value = olMail.To
If Range("C" & i).Value Like "*MailID comes here*" Then
Range("A" & i).Value = olMail.Subject
Range("B" & i).Value = olMail.SentOn
Range("D" & i).Value = olMail.CC
Range("E" & i).Value = olMail.Body
olMail.UnRead = False
Call Macro1(i)
Else
Range("C" & i).Select
Selection.ClearContents
i = i - 1
End If
End If
Next olMail
ActiveWorkbook.Save
Set olApp = Nothing
Set olNS = Nothing
Set Fldr = Nothing
End Sub