Outlook 2003/2007 Rule and Conditions for InBox VBA customization

Status
Not open for further replies.
R

R3JleUNvZGVySUk

I would like Outlook to periodically examine my inbox items to do some

automated cleanup. Unfortunately the basic functionality of Rules Wizard does

not provide the two Conditions and Time interval setting I need to test to

apply an action. So I believe I must write a VBA Script to perform the

actions.

Outlook (out of the box) seems to be missing ability to set conditions on

any of the MailBoxItem properties (only some...) , and is missing a Check

Messages Periodically interval where Check either when arrive or when sent

exists.

I want to daily (After midnight) check all InBox items that are from certain

addresses (condition for rule exists), AND where the Item Property is

MailBoxItem.UnRead (does not exist in selection conditions presently) , and

the Item.DateReceived is > 7 days from todays date ie: item is older than 7

days, and then Move the item to another folder (Action can be set in current

Rules choices)

I am not VB/VBA programmer but I have done a little VB work , There are no

samples (or MS documentation) around that define all of the pieces I require

to write the Macro.

1) How to define and add new Conditions to existing Outlook Rule condition

choices?

2) How to Return a Boolean result from a Macro to be used in Rule condition

/action testing? ie: Return (Item.UnRead = True) ?? probably obvious to a VB

programmer .

3) What are the arguments required I assume MailBoxItem is passed as input

argument to all VBA Macros/Scripts called from OutLook client, it's weakly

documented.

4) How to set Rule execution interval to daily , and Inbox iteration?

5) What are all the properties of MailBoxItem ( I actually think it's out

there in bits and pieces.) I found UnR

6) What is the environment the VBA rule runs under ie: Context is already in

Application.Inspector or something or do all objects

Outlook/Application/Inspector etc.. need definition (Dim... As) as well as

Set (... = ???) for useage (This is probably obvious to a VB programmer..

Perhaps I will have to write an extension or Add in instead ?? seems silly

> ... but.

Any help on how to write a rule to do what I want is appreciated.

GC
 
K

Ken Slovak - [MVP - Outlook]

A rule can call a script, which is a macro Sub with a signature that accepts

a passed MailItem. There can be no return value from a Sub, you'd have to

set a global variable.

In the context of Outlook VBA there is an Application object that always

refers to Outlook.Application.

To see the properties/methods/events exposed for any Outlook object use the

Object Browser (F2 in the Outlook VBA project). It's all in one place and

there's help available on any method/property/event by clicking F1 on

something in the Object Browser.

Unless you are using only Outlook 2007 you cannot define rules using code.

For Outlook 2007 you can use the new Rules collection, but what's available

there may or may not meet your needs. You'd have to see.

There may not be a code sample for everything you want, but there are

certainly all the bits and pieces. You can search at www.outlookcode.com for

samples covering the various pieces you want.

There is no way to run a rule at a timed interval in any version of Outlook.

You would need to use some sort of timer control to activate your code,

which would then have to call VBA macros to do the processing. If you have

VB6 installed you can put a timer control from that environment into a VBA

UserForm, otherwise you'd need to probably use a Win32 API timer class. You

can google for code that does that using VB6 at VBAccelerator.com, some

translation from VB6 to VBA would be required.

Once you have a timer established how you proceed from the timer event

handler depends on your Outlook version.

If you are using Outlook 2003 you can't call a rule from code so you'd need

to code things entirely without using rules.

For Outlook 2007, assuming that the available Rule object model can do what

you want you can instantiate a Rule object for that rule and call its

Execute method to execute the rule.

If the Rule object model can't do what you want you're back to pure VBA

code, without using rules at all.

"GreyCoderII" <GreyCoderII> wrote in message

news:F148459F-926A-4A56-B89F-BACF5DD32EFD@microsoft.com...
> I would like Outlook to periodically examine my inbox items to do some
> automated cleanup. Unfortunately the basic functionality of Rules Wizard
> does
> not provide the two Conditions and Time interval setting I need to test to
> apply an action. So I believe I must write a VBA Script to perform the
> actions.

> Outlook (out of the box) seems to be missing ability to set conditions on
> any of the MailBoxItem properties (only some...) , and is missing a Check
> Messages Periodically interval where Check either when arrive or when sent
> exists.

> I want to daily (After midnight) check all InBox items that are from
> certain
> addresses (condition for rule exists), AND where the Item Property is
> MailBoxItem.UnRead (does not exist in selection conditions presently) ,
> and
> the Item.DateReceived is > 7 days from todays date ie: item is older than
> 7
> days, and then Move the item to another folder (Action can be set in
> current
> Rules choices)

> I am not VB/VBA programmer but I have done a little VB work , There are
> no
> samples (or MS documentation) around that define all of the pieces I
> require
> to write the Macro.
> 1) How to define and add new Conditions to existing Outlook Rule condition
> choices?
> 2) How to Return a Boolean result from a Macro to be used in Rule
> condition
> /action testing? ie: Return (Item.UnRead = True) ?? probably obvious to a
> VB
> programmer .
> 3) What are the arguments required I assume MailBoxItem is passed as input
> argument to all VBA Macros/Scripts called from OutLook client, it's weakly
> documented.
> 4) How to set Rule execution interval to daily , and Inbox iteration?
> 5) What are all the properties of MailBoxItem ( I actually think it's out
> there in bits and pieces.) I found UnR
> 6) What is the environment the VBA rule runs under ie: Context is already
> in
> Application.Inspector or something or do all objects
> Outlook/Application/Inspector etc.. need definition (Dim... As) as well as
> Set (... = ???) for useage (This is probably obvious to a VB programmer..

> Perhaps I will have to write an extension or Add in instead ?? seems silly
> ... but.

> Any help on how to write a rule to do what I want is appreciated.
> GC
>
 
R

R3JleUNvZGVySUk

Thank you Ken. Looks like I'll need to do some research and amalgamation of

techniques etc., the guideposts you suggested help .

Should there not be a way in which I could derive and enhance existing forms

and values and dialogs to add what I want?, ie: I wonder if I can wrap/derive

extend existing classes in Outlook Rules Wizard (Start from Blank rule) (and

add) a timer event so rule wizard lists "Check item in this folder Daily" ,

and Conditions for testing in Macro's Ie add a condition "If item is unread"

and condition "If Item is older than n days" . I guess the timer even routine

would need to examine the rules tree, etc...

Perhaps I should investigate a C# Plugin and add Timer etc.. And new

dialogs etc. It would just seem better to use existing UI and just add the

extensions to the existing UI and classes and selection string values etc...

I'll look at Outlook 2007 Rule Object model and probably only Outlook 2007

and later .

"GreyCoderII" wrote:


> I would like Outlook to periodically examine my inbox items to do some
> automated cleanup. Unfortunately the basic functionality of Rules Wizard does
> not provide the two Conditions and Time interval setting I need to test to
> apply an action. So I believe I must write a VBA Script to perform the
> actions.

> Outlook (out of the box) seems to be missing ability to set conditions on
> any of the MailBoxItem properties (only some...) , and is missing a Check
> Messages Periodically interval where Check either when arrive or when sent
> exists.

> I want to daily (After midnight) check all InBox items that are from certain
> addresses (condition for rule exists), AND where the Item Property is
> MailBoxItem.UnRead (does not exist in selection conditions presently) , and
> the Item.DateReceived is > 7 days from todays date ie: item is older than 7
> days, and then Move the item to another folder (Action can be set in current
> Rules choices)

> I am not VB/VBA programmer but I have done a little VB work , There are no
> samples (or MS documentation) around that define all of the pieces I require
> to write the Macro.
> 1) How to define and add new Conditions to existing Outlook Rule condition
> choices?
> 2) How to Return a Boolean result from a Macro to be used in Rule condition
> /action testing? ie: Return (Item.UnRead = True) ?? probably obvious to a VB
> programmer .
> 3) What are the arguments required I assume MailBoxItem is passed as input
> argument to all VBA Macros/Scripts called from OutLook client, it's weakly
> documented.
> 4) How to set Rule execution interval to daily , and Inbox iteration?
> 5) What are all the properties of MailBoxItem ( I actually think it's out
> there in bits and pieces.) I found UnR
> 6) What is the environment the VBA rule runs under ie: Context is already in
> Application.Inspector or something or do all objects
> Outlook/Application/Inspector etc.. need definition (Dim... As) as well as
> Set (... = ???) for useage (This is probably obvious to a VB programmer..

> Perhaps I will have to write an extension or Add in instead ?? seems silly
> ... but.

> Any help on how to write a rule to do what I want is appreciated.
> GC
>
 
K

Ken Slovak - [MVP - Outlook]

Those ideas are nice but they don't buy you anything, nor does a COM addin.

There's nothing you can do there that you can't do in VBA, other than use a

different timer object. My guess is that you will end up having to do what I

suggested.

"GreyCoderII" <GreyCoderII> wrote in message

news:4A8DB91F-CC55-47C3-B9F1-2BD0FAD411CE@microsoft.com...
> Thank you Ken. Looks like I'll need to do some research and amalgamation
> of
> techniques etc., the guideposts you suggested help .

> Should there not be a way in which I could derive and enhance existing
> forms
> and values and dialogs to add what I want?, ie: I wonder if I can
> wrap/derive
> extend existing classes in Outlook Rules Wizard (Start from Blank rule)
> (and
> add) a timer event so rule wizard lists "Check item in this folder Daily"
> ,
> and Conditions for testing in Macro's Ie add a condition "If item is
> unread"
> and condition "If Item is older than n days" . I guess the timer even
> routine
> would need to examine the rules tree, etc...

> Perhaps I should investigate a C# Plugin and add Timer etc.. And new
> dialogs etc. It would just seem better to use existing UI and just add the
> extensions to the existing UI and classes and selection string values
> etc...
> I'll look at Outlook 2007 Rule Object model and probably only Outlook 2007
> and later .
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
D outlook 2003/2007 macro query Using Outlook 2
D Calendar Permissions Outlook 2003, 2007 and 2010 Exchange Server Administration 2
G Is there any way to convert outlook 2003 to outlook 2007 Using Outlook 5
D Outlook 2007 contacts do not show up in address book - 97-2003 pst file Using Outlook 0
J Outlook 2003/2007 IMAP emails dont show in inbox Using Outlook 0
K Outlook 2007 vs Outlook 2003 Using Outlook 1
V Outlook Connector not syncing to Outlook 2003 AND 2007 Using Outlook.com accounts in Outlook 1
M Iterating a Contacts folder for Outlook 2003 and 2007 in C# Outlook VBA and Custom Forms 8
F Outlook 2003 form cannot be loaded in 2007 Outlook VBA and Custom Forms 1
M Business contact manager 2003 on outlook 2007 BCM (Business Contact Manager) 1
K Outlook 2003 to 2007 data transfer Using Outlook 3
A COM add-in causes Outlook 2007 to periodically crash where it did not in Outlook 2003 Outlook VBA and Custom Forms 3
K Is it possible to use BCM 2003 with Outlook 2007? BCM (Business Contact Manager) 4
S Can Outlook 2007 calendar match the Outlook 2003 calendar? Using Outlook 3
U Installing Outlook 2003 instead of 2007 Using Outlook 2
C Outlook 2003 Add-in doesn't work on Outlook 2007 Outlook VBA and Custom Forms 1
B Re: Outlook 2003 Add-in doesn;t work on Outlook 2007 Outlook VBA and Custom Forms 2
B Outlook 2003/2007 and New Mail Desktop Alerts Outlook VBA and Custom Forms 4
J Outlook 2007 using custom form created for Outlook 2003 Outlook VBA and Custom Forms 2
B Outlook 2007 Custom Form does not display in 2003 Outlook VBA and Custom Forms 3
glnz Moving from Outlook 2003 to MS365 Outlook - need basics Using Outlook 4
I Outlook 2003 shows html code when To: field is empty Using Outlook 7
B Outlook 2003 email sending & receiving suddenly stopped working Using Outlook 3
H Outlook 2003 find by "has attachment" Using Outlook 1
glnz How set up new IMAP on Outlook-Office 365 and merge in pst from Outlook 2003 for same two email accounts? Using Outlook 5
P Import Categories from Outlook 2003 Using Outlook 8
V Outlook 2003 problem with Windows 10 Creators Update 1709 Using Outlook 0
M Outlook 2003 pictures - some visible, some not Using Outlook 0
S Outlook 2003 to Outlook 2013 pst file Using Outlook 5
O Memory Leak in Outlook 2003 Using Outlook 3
W Changing looks of emails in Outlook 2003 Using Outlook 0
O Outlook 2003 can't send, but settings seem OK Using Outlook 1
P URL Hyperlink not working correctly in Outlook 2003 Using Outlook 10
O Outlook 2003 can't open contacts. Using Outlook 2
O Promoting Outlook 2003 User Templates Using Outlook 1
O W-a-a-y too many PSTs (Outlook 2003) Using Outlook 0
J Outlook 2003-2010 PST Field Editor Using Outlook 1
P Outlook 2003 - Do I need a new profile? Using Outlook 2
E Want to Import Outlook 2003 pst files to later version Using Outlook 6
A error message outlook 2003 Using Outlook 1
B Seeking advice now Outlook 2003 is unsupported by Exchange Using Outlook 4
O Change Debit to Credit in Outlook 2003? Using Outlook 1
J problems downloading POP3 emails to Outlook 2003 Using Outlook 1
G Outlook 2003 VBA Won't Run In Outlook 2010 Outlook VBA and Custom Forms 4
P Outlook 2003 - possible to recreate corrupt account? Using Outlook 3
Calvyn Outlook 2003 cannot import .vcs subject Using Outlook 1
T Query about one aspect of migrating .pst files from Outlook 2003 to Outlook 2013 Using Outlook 5
C Outlook 2003 contacts Using Outlook 1
G Configuring Outlook 2003 for Gmail with both pop3 & imap4 accounts Using Outlook 1
M HELP--Extract Data from 2003 outlook transfer to excel spreadsheet Using Outlook 1

Similar threads

Top