Mark junk items as unread

  • Thread starter Thread starter Philip Brown
  • Start date Start date
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 have the same problem as you, but I don't know how to program Outlook2000
to use your code. Can you explain? Thanks
 
Hi, Renae,

Two options:
#1
In Outlook type ALT+F11, double-click Project1, double-
click Microsoft Outlook Objects, double-click
ThisOutlookSession. Paste the code in this window, save
the project, and you're through. Close out the Microsoft
Visual Basic window

#2
Download Spambayes from Spambayes.com and install. This
automatically sorts email and has the option to mark Junk
mail as read.
 
Excellent post Philip. I've been looking for this for months. I know
VBA but not a lot of the Outlook specific syntax, so this saved me a
learning experience I would not have utilized for other things.

Thanks again.
 
THanks Philip. I tried to do the same thing (I thought)
and got a run-time error saying the Property was Read
Only. Not sure what I was doing but adding MyItem.UnRead
= False works. Thanks again!
 
Greetings! This works great for one folder? How could one apply thi
to multiple folders?

Thanks!
 
Back
Top