-
Selecting only categorized emails
Hi,
I'm looking to loop through all the emails in my inbox and select only those that have been categorized. For example, say I have 3 messages, the first has been categorized as "Red", the second is not categorized and the third is categorized as "Blue". I would like to write code to only select and open emails one and three.
Anyone have some advice on how to do this?
Thanks!
Mike
-
[vba]
Sub SearchAndDisplay_Category()
Dim olApp As Outlook.Application
Dim olNS As Outlook.Namespace
Dim olInbox As Outlook.MAPIFolder
Dim olItem As Object
Dim I As Long
Set olApp = Outlook.Application
Set olNS = olApp.GetNamespace("MAPI")
Set olInbox = olNS.GetDefaultFolder(olFolderInbox)
For I = olInbox.items.Count To 1 Step -1
Set olItem = olInbox.items(I)
If olItem.Categories <> "" Then
olItem.Display
End If
Next I
Set olApp = Nothing
Set olNS = Nothing
Set olInbox = Nothing
Set olItem = Nothing
End Sub
[/vba]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules