P
Philip Brown
Hello,
I posted a request several days ago for help to know how
to mark items moved to a junk folder as read. Several
similar requests have been posted to the list without any
response.
Since then I've figured it out and figured I'd share it
for others searching for similar help. The following
code does the trick:
Public WithEvents myOlItems As Outlook.Items
Public Sub Application_Startup()
Dim objNS As NameSpace
Dim objInbox As MAPIFolder
' Reference the items in the Inbox. Because myOlItems
' is declared "WithEvents" the ItemAdd event will fire
' below.
Set objNS = Application.GetNamespace("MAPI")
Set objInbox = objNS.Folders.Item("Personal Folders")
Set myOlItems = objInbox.Folders("Junk E-Mail").Items
End Sub
Public Sub myOlItems_ItemAdd(ByVal Item As Object)
' Verify item is a mailitem
If TypeName(Item) = "MailItem" Then
With Item
.UnRead = False
.Save
End With
End If
End Sub
I posted a request several days ago for help to know how
to mark items moved to a junk folder as read. Several
similar requests have been posted to the list without any
response.
Since then I've figured it out and figured I'd share it
for others searching for similar help. The following
code does the trick:
Public WithEvents myOlItems As Outlook.Items
Public Sub Application_Startup()
Dim objNS As NameSpace
Dim objInbox As MAPIFolder
' Reference the items in the Inbox. Because myOlItems
' is declared "WithEvents" the ItemAdd event will fire
' below.
Set objNS = Application.GetNamespace("MAPI")
Set objInbox = objNS.Folders.Item("Personal Folders")
Set myOlItems = objInbox.Folders("Junk E-Mail").Items
End Sub
Public Sub myOlItems_ItemAdd(ByVal Item As Object)
' Verify item is a mailitem
If TypeName(Item) = "MailItem" Then
With Item
.UnRead = False
.Save
End With
End If
End Sub