Rules - how to determine if all conditions in rule are true or false

Status
Not open for further replies.

Andrzej

New Member
Outlook version
Outlook 2010 64 bit
Email Account
POP3
Dear Forum Users,
I am trying to get know if all conditions in a single rule return true or false.
How to get know that by VBA (programmatically) ?
For example I have a rule:

If subject or body contains "AC4" or "AC 4" or AC/4" forward it to AC4 group and run a script "Project1.ThisOutlookSession.test"

I want script "test" to return true if above conditions are fulfil or false if not.
I really appreciate your help.

Regards,
Andrzej Nizankowicz
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
i have a lot of samples here - Outlook's Rules and Alerts: Run a Script

If one of those values is true in the rule, it passes it on to the script. if the script doesn't run, it can't return false.

If you want to test all messages, you could either use a rule with no conditions then use an if statement to test or use an itemadd macro to test messages that arrive in the inbox.

The if would read something like :

if instr(1, item.body, "AC4") > 0 or instr(1, item.body, "AC 4") > 0 or instr(1, item.body, "AC/4") > 0 then
' do whatever if true
else
'do whatever if not true
end if

This will work to wild card the separator - it will find AC/4, AC 4, and ACL4 - which may or may not work for you.
If UCase(Item.Body) Like UCase("*AC?4*") = True Or InStr(1, Item.Body, "AC4") > 0 Then
' do whatever
else
'do whatever
end if
 

Andrzej

New Member
Outlook version
Outlook 2010 64 bit
Email Account
POP3
Diane,
Thank you very much for the answer.
I thought rather about solution which is based on already existing objects. Somehow rules must know if to execute a single rule or not... If there is no other method I will have to do that your way :)
Does anyone has another suggestion?
Regards,
Andrzej
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
If you want the script to return true or false, then it needs to do the testing - and test all messages (or test all messages meeting a specific condition, such as from internet addresses.

You could also use two rules - one looking for the words and have it run the script then a second rule applying to all mail - if they are in this order with 'stop processing' enabled, it will work (but you could add an exception for the conditions in the first rule as a fail safe), but it can't be done in one rule.

BTW - you should do all actions in a script - it's prone to fail if you mix actions with a script.
forward it to AC4 group and run a script
 

Andrzej

New Member
Outlook version
Outlook 2010 64 bit
Email Account
POP3
Dear Diane,
Once again thank you. I found another solution. I put a script to every rule. If rule meets conditions to run, it runs also the script. Then I don't have to check if sum of conditions in a rule is true!
I hope this will work - I am going to check it soon.
Regards,
Andrzej
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
That *should* work - but it's not recommended to mix actions in the rule with scripts - once the message is handed off to the script, the rule stops and additional actions will be skipped.

If you are trying to identify which rule is affecting each message, add a category to the message, where the category name is the rule name.
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
Aussie Rules Run a Script on an Incoming Email OK and then the Email reverts Outlook VBA and Custom Forms 0
R rules not working - done troubleshooting Using Outlook 0
P Outlook 2013 All imported Mail Rules in error when imported into new profile Using Outlook 5
A Apply Selected Emails to outlook rules and Run Rules Using Outlook 5
Wayne Outlook locks up when opening "Manage Rules & Alerts" Using Outlook 7
T "Words In Recipient's Address" Rule Causes Outlook To Stop Processing Rules Using Outlook 3
Retired Geek Junk Folder Clean Up Rules Exchange Server Administration 1
B Setting rules Using Outlook 1
A rules not working Using Outlook 2
M Rules and autoreply Using Outlook 1
N Outlook rules don't create a copy for bcc'ed emails Using Outlook 3
O How to recover rules after switch from POP3 to IMAP Using Outlook 2
N Focussed Inbox Rules Failing Using Outlook 5
N Copies of emails from rules have wrong from: account Using Outlook 0
L Office 365 cloud based rules Using Outlook 1
K Outlook Rules: Move a Copy Using Outlook 4
CWM030 Rules disappearing in OL 2016? ( Yes, I searched before posting) Using Outlook 7
R When rules lose track of "specified folder" Using Outlook 6
I Outlook 2013 Rules - (client only) Using Outlook.com accounts in Outlook 1
B When I add more search strings to RULES, it is not processing them Using Outlook 3
O Having rules run on old mails noved to inbox Outlook VBA and Custom Forms 8
A rules (flags) not working Using Outlook 7
K Lost Rules. Assistant accesses my mailbox. Disappeared Using Outlook 0
soadfan Outlook rules look up display name only Using Outlook 4
S Send email via SMTP - use transport rules to add to senders inbox (then rule to move to sent items Exchange Server Administration 1
Justo Horrillo Issue with rules in Outlook 2010 Using Outlook 4
J Outlook Rules - Changing auto-submit address in multiple rules, according to rule name Outlook VBA and Custom Forms 0
R When rules are working but invisible and unmanageable Using Outlook 2
P Transport Agent or Rules/Connectors Exchange Server Administration 1
EaglePI Outlook 2010 need help with rules Using Outlook 0
O Rules and Alerts for New Messages BEFORE sending Using Outlook 2
D Outlook Rules Using Outlook 1
Diane Poremsky Autoaccept a Meeting Request using Rules New Slipstick.com Articles 2
K adding more rules to 'different domains check' macro Outlook VBA and Custom Forms 2
Gunny NFOhiway Outlook PST file and Rules Using Outlook 1
M Outlook 2016 Rules Not Working Automatically Using Outlook 5
Diane Poremsky Rules & Alerts Dialog Won't Open New Slipstick.com Articles 1
soadfan Enable all rules from toolbar button? Outlook VBA and Custom Forms 3
oliv- How to Run a Script IN AN ADDIN with Outlook's Rules and Alerts Outlook VBA and Custom Forms 2
P Log of Rules that ran Outlook VBA and Custom Forms 3
Q Outlook 2016\365 export specific rules to import in another system Exchange Server Administration 1
S Rules to auto redirect Using Outlook 5
P Recover / Extract Rules from standalone PST file creating RWZ file Using Outlook 2
T Client-side rules not working, but no error Using Outlook 1
R Missing Quick Steps and Rules Using Outlook 0
Diane Poremsky Delegates, Meeting Requests, and Rules New Slipstick.com Articles 0
A outlook 2007 how to chcek all rules ? Outlook VBA and Custom Forms 2
J Outlook Rules not show Master Category List Using Outlook.com accounts in Outlook 4
mikecox Forward email to another address; not with Rules Using Outlook 3
T VBA to Sort Rules [A-Z] - code provided Outlook VBA and Custom Forms 9

Similar threads

Top