J
John
Hi,
I'm trying to run a single rule against my "Junk E-mail" folder. Poking
around on forums, I twisted some code a bit to successfully run the rule
(albeit using what must be an inefficient loop to find the right rule).
However, it runs against the Inbox, and not Junk E-mail. I can't quite
figure out how to get it to run against the right folder. It must be the
Folder parm of the rl.Execute statement, but I don't know how to construct it.
Here is what I am doing:
Sub Kill_Junk()
Dim st As Outlook.Store
Dim myRules As Outlook.Rules
Dim rl As Outlook.Rule
Dim count As Integer
Dim ruleList As String
'On Error Resume Next
' get default store (where rules live)
Set st = Application.Session.DefaultStore
' get rules
Set myRules = st.GetRules
' iterate all the rules
For Each rl In myRules
' determine if it's an Inbox rule
If rl.Name = "Delete Most Junk Mail" Then
' if so, run it
rl.Execute ShowProgress:=True
End If
Next
Set rl = Nothing
Set st = Nothing
Set myRules = Nothing
End Sub
I'm trying to run a single rule against my "Junk E-mail" folder. Poking
around on forums, I twisted some code a bit to successfully run the rule
(albeit using what must be an inefficient loop to find the right rule).
However, it runs against the Inbox, and not Junk E-mail. I can't quite
figure out how to get it to run against the right folder. It must be the
Folder parm of the rl.Execute statement, but I don't know how to construct it.
Here is what I am doing:
Sub Kill_Junk()
Dim st As Outlook.Store
Dim myRules As Outlook.Rules
Dim rl As Outlook.Rule
Dim count As Integer
Dim ruleList As String
'On Error Resume Next
' get default store (where rules live)
Set st = Application.Session.DefaultStore
' get rules
Set myRules = st.GetRules
' iterate all the rules
For Each rl In myRules
' determine if it's an Inbox rule
If rl.Name = "Delete Most Junk Mail" Then
' if so, run it
rl.Execute ShowProgress:=True
End If
Next
Set rl = Nothing
Set st = Nothing
Set myRules = Nothing
End Sub