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
#1
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
 
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
#2
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
#3
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
 
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
#4
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
#5
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
 
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
#6
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

Top