Link to home
Create AccountLog in
Outlook

Outlook

--

Questions

--

Followers

Top Experts

Avatar of newknew
newknew

Bulk rules editing in MS Outlook
I see a way to export rules in Outlook 2010, but the exported file is not text, csv, etc.  Is there a tool to bulk edit Outlook rules similar to safelist editing?

Why?  Because I have 200 rules that handle 200 aliases and route them to folders based on priority.  I want to change them easily "offline" in Excel then upload back into Outlook.

If it matters, I'm using Outlook against an Exchange server account.

Zero AI Policy

We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.


Avatar of Chris BottomleyChris Bottomley🇬🇧

It is possible in 2010 to read some of the rule data in VBA, it is also possible to add rules via VBA so I am not sure if it is possible to edit rules but it should be possible to delete all and recreate all using stored (editable therefore) data Assumig use of VBA is acceptable and the rules themselves can all be entered as VBA.

If you can advise the rules nature, i.e. move, copy or whatever and what they apply to then I can try some experimentation.   It is also possible someone will pop up that has already done it!, so the data will help them as well.

Chris

Avatar of newknewnewknew

ASKER

There are only two versions of all the rules:

After message is received:
1) if header data contains "email@domain.com" then move to specified folder / end processing
2) if sent to equals "email@domain.com" then move to specified folder / end processing

Thanks!

Took a long while to figure out the syntax ....

Two subs, one demonstrates a check of the header and the second the senders email.

Basically you need to decide how you want to cycle through data and then call the equivalent code.  Potentially this will be via conversion to a function but the basic mechanism is as presented here.

Chris
Sub CreateRuleHeader()
Dim olkRules As Outlook.Rules
Dim olkRule As Outlook.Rule
Dim olkCondition As Outlook.TextRuleCondition
Dim olkAction As Outlook.MoveOrCopyRuleAction
    
    Set olkRules = Outlook.Application.Session.DefaultStore.GetRules()
    On Error Resume Next
    Set olkRule = olkRules.Item("Fred")
    On Error GoTo 0
    If olkRule Is Nothing Then Set olkRule = olkRules.Create("Fred", olRuleReceive)
    With olkRule
        Set olkCondition = .Conditions.MessageHeader
        olkCondition.Text = Array("fred@fred.com")
        olkCondition.Enabled = True
        Set olkAction = .Actions.moveToFolder
        olkAction.Folder = Application.Session.GetDefaultFolder(olFolderinbox).folders("fred")
        .Actions.Stop.Enabled = True
        olkAction.Enabled = True
    End With
    olkRules.Save
    
Set olkAction = Nothing
Set olkCondition = Nothing
Set olkRule = Nothing
Set olkRules = Nothing
End Sub

Sub CreateRuleFrom()
Dim olkRules As Outlook.Rules
Dim olkRule As Outlook.Rule
Dim olkCondition As Outlook.AddressRuleCondition
Dim olkAction As Outlook.MoveOrCopyRuleAction
    
    Set olkRules = Outlook.Application.Session.DefaultStore.GetRules()
    On Error Resume Next
    Set olkRule = olkRules.Item("Doris")
    On Error GoTo 0
    If olkRule Is Nothing Then Set olkRule = olkRules.Create("Doris", olRuleReceive)
    With olkRule
        Set olkCondition = .Conditions.SenderAddress
        olkCondition.address = Array("fred@fred.com")
        olkCondition.Enabled = True
        Set olkAction = .Actions.moveToFolder
        olkAction.Folder = olkNav2Folder(Application.Session.GetDefaultFolder(olFolderinbox).FolderPath & "\fred", True)
        olkAction.Enabled = True
    End With
    olkRules.Save
    
Set olkAction = Nothing
Set olkCondition = Nothing
Set olkRule = Nothing
Set olkRules = Nothing
End Sub

Open in new window


Reward 1Reward 2Reward 3Reward 4Reward 5Reward 6

EARN REWARDS FOR ASKING, ANSWERING, AND MORE.

Earn free swag for participating on the platform.


Avatar of newknewnewknew

ASKER

Thanks, I'll need some time to try this out.

In the second rule, I'm actually checking the "sent to address" (not sender)  Can you tell me the proper condition parameter, or post a list/link to all of them?

POst a link, as far as I know there is no clear definition ... I have been using trial and error so i'll do a bit more and get back to you.

Chris

ASKER CERTIFIED SOLUTION
Avatar of Chris BottomleyChris Bottomley🇬🇧

Link to home
membership
Log in or create a free account to see answer.
Signing up is free and takes 30 seconds. No credit card required.
Create Account

Avatar of newknewnewknew

ASKER

one last question if you don't mind... how can I "feed" this Sub a list of the input values? say from a copy/paste spreadsheet, comma delimited list, etc.  - doesn't have to be from a file, I can paste the values in the Sub either from spreadsheet for from an exported file generated from Excel.

Raising points accordingly.

Free T-shirt

Get a FREE t-shirt when you ask your first question.

We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.

Outlook

Outlook

--

Questions

--

Followers

Top Experts

Microsoft Outlook is a personal information manager from Microsoft, available as a part of the Microsoft Office suite. Although often used mainly as an email application, it also includes a calendar, task manager, contact manager, note-taker, journal, and web browser.