DavidHaley
01-29-2017, 12:27 PM
Okay, so...in Outlook, for some reason...spam makes it through my rules and hits my junk mailbox. If I run the rules manually...it catches them and deletes them. I don't want to have to go through the steps of clicking through the rule dialogue box in order to run all rules manually so...I'd like to have a script that I can put in my quick access toolbar. I know, I know...why worry about junk...well...I get some spam that has pretty offensive words in the subject from time-to-time and...I don't want those to even show up! Plus I get tons of spam in general and I don't want to have to look at 100's of email to determine whether or not any of them are not spam.
The script below is set up for the default mailbox, which is my work account...which I don't have to worry about...work has spam nailed down pretty well. I need the script below altered to work for a secondary account which is my Hotmail account. Can anyone help me out with this?
I didn't use tags because...for some reason it makes the script below look like gibberish!
Thank you in advance for you help!
Sub RunAllInboxRules()
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.RuleType = olRuleReceive Then
‘ if so, run it
rl.Execute ShowProgress:=True
count = count + 1
ruleList = ruleList & vbCrLf & rl.Name
End If
Next
‘ tell the user what you did
ruleList = “These rules were executed against the Inbox: ” & vbCrLf & ruleList
MsgBox ruleList, vbInformation, “Macro: RunAllInboxRules”
Set rl = Nothing
Set st = Nothing
Set myRules = Nothing
End Sub
The script below is set up for the default mailbox, which is my work account...which I don't have to worry about...work has spam nailed down pretty well. I need the script below altered to work for a secondary account which is my Hotmail account. Can anyone help me out with this?
I didn't use tags because...for some reason it makes the script below look like gibberish!
Thank you in advance for you help!
Sub RunAllInboxRules()
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.RuleType = olRuleReceive Then
‘ if so, run it
rl.Execute ShowProgress:=True
count = count + 1
ruleList = ruleList & vbCrLf & rl.Name
End If
Next
‘ tell the user what you did
ruleList = “These rules were executed against the Inbox: ” & vbCrLf & ruleList
MsgBox ruleList, vbInformation, “Macro: RunAllInboxRules”
Set rl = Nothing
Set st = Nothing
Set myRules = Nothing
End Sub