For now, I've got a VBA fix in place and it works fine. However, I'd be keenly interested to know if anyone knows of a solution to the issue of the rules not running automatically.
I recently went through my Outlook rules and cleared out old names for folks who left the company, moved, whatever, and added a few that I didn't already have in my rules. I don't think I made any major changes.
During that time, I had a couple instances where I'd get the message stating that "one or more rules have been disabled" because I apparently (I guess) had one email address in more than one rule... or I think it also happens if someone leaves the company and their Outlook contact is now NULL, but I'm not 100% sure - it just seems to be the case on occasion.
So, it was driving me batty for about the past half a week to 1 full week. So this morning, I went looking around on the web. I didn't find an immediate solution, but I did cobble together a VBA solution.
First, I found some code that runs all rules for you whenever it is called. It's not complex code at all, but since it was already there, I just used that instead of typing myself:
I commented out the MsgBox piece, b/c I don't want it popping up every time it runs.
And then I found another bit of code that someone put together for running anything on a set time. Well, that would work, but I don't want to be running something every few seconds if it's not necessary. So I thought of a better option.
I found the Application_NewMail() item in Outlook, and just called the RunAllInboxRules procedure from there. So that code looks like:
That last piece is in the ThisOutlookSession object, and the other is in its own standard module.
So this is working just fine. However, if anyone knows of a fix outside running via VBA, I'd like to know that and try it as well. I could not find any definite clues to it in my searching this morning.
I recently went through my Outlook rules and cleared out old names for folks who left the company, moved, whatever, and added a few that I didn't already have in my rules. I don't think I made any major changes.
During that time, I had a couple instances where I'd get the message stating that "one or more rules have been disabled" because I apparently (I guess) had one email address in more than one rule... or I think it also happens if someone leaves the company and their Outlook contact is now NULL, but I'm not 100% sure - it just seems to be the case on occasion.
So, it was driving me batty for about the past half a week to 1 full week. So this morning, I went looking around on the web. I didn't find an immediate solution, but I did cobble together a VBA solution.
First, I found some code that runs all rules for you whenever it is called. It's not complex code at all, but since it was already there, I just used that instead of typing myself:
Code:
Sub RunAllInboxRules()
'from [URL unfurl="true"]http://www.outlookcode.com/codedetail.aspx?id=1266[/URL]
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
And then I found another bit of code that someone put together for running anything on a set time. Well, that would work, but I don't want to be running something every few seconds if it's not necessary. So I thought of a better option.
I found the Application_NewMail() item in Outlook, and just called the RunAllInboxRules procedure from there. So that code looks like:
Code:
Private Sub Application_NewMail()
RunAllInboxRules
End Sub
That last piece is in the ThisOutlookSession object, and the other is in its own standard module.
So this is working just fine. However, if anyone knows of a fix outside running via VBA, I'd like to know that and try it as well. I could not find any definite clues to it in my searching this morning.