J
John
Hi,
Poking around forums I have managed to create a macro to run a rule for me,
but I can't seem to figure out how to tell it to run against something other
than the Inbox. I think it is just another parm on the rl.Execute line, but
I don't know how to construct it (it's not Folder:="Junk E-mail" of that I am
sure).
Here is an abbreviated version of what I have:
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
--
Any help appreciated. My loop to find the one rule I want seems like a
"bad" way to do it, but is all I have come up with so far.
Thanks.
John
Poking around forums I have managed to create a macro to run a rule for me,
but I can't seem to figure out how to tell it to run against something other
than the Inbox. I think it is just another parm on the rl.Execute line, but
I don't know how to construct it (it's not Folder:="Junk E-mail" of that I am
sure).
Here is an abbreviated version of what I have:
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
--
Any help appreciated. My loop to find the one rule I want seems like a
"bad" way to do it, but is all I have come up with so far.
Thanks.
John