Dear Experts
I am using below code to search for email in out look. It works good, but all serach results (ie Emails) are opening one by one and out look gets stuck (there will be lots of email containing given key word).
Can anybody pls help me to get a code to list all emails containing given key word ("City Pharmacy") in out look seach box only instead opening one by one.
>>> use code - tags <<<
I am using below code to search for email in out look. It works good, but all serach results (ie Emails) are opening one by one and out look gets stuck (there will be lots of email containing given key word).
Can anybody pls help me to get a code to list all emails containing given key word ("City Pharmacy") in out look seach box only instead opening one by one.
>>> use code - tags <<<
Code:
Sub Test()
'this is working but all windows are opending one by one.
Dim olApp As Outlook.Application
Dim olNs As Namespace
Dim Fldr As MAPIFolder
Dim olMail As Variant
Dim i As Integer
Set olApp = New Outlook.Application
Set olNs = olApp.GetNamespace("MAPI")
Set Fldr = olNs.GetDefaultFolder(olFolderInbox)
i = 1
For Each olMail In Fldr.Items
If InStr(olMail.Subject, "City Pharmacy") <> 0 Then
olMail.Display
i = i + 1
End If
Next olMail
End Sub
Last edited by a moderator: