Processing of all new messages in Outlook Inbox folder

J

John Stratoudakis

I have been researching the topic of performing an operation (SPAM
detection) on each incoming message to the users inbox (regardless of
all rules performed on the message) for Outlook 2000, XP and 2003.

I have experimented with the Outlook - NewMail event, and I have heard
that if the number of incoming messages is above a certain number (some
say 16) that the event will fire once instead of 16+x times, and I have
also heard that the same thing occurs when using the Outlook Redemption
NewMail event, which also includes a reference to the new mailitem.
(If the author of Outlook Redemption is reading, I have to say thats
its a great tool, and if I am wrong, please correct me)

I have also experimented by monitoring the ItemAdd event of the Default
inbox of the current outlook session and have come to the conclusion
that the same thing occurs there as well, where every single message
that is added to the Inbox fires an event unless more than a certain
number of messages are added in bulk at the same time (such as the user
pressing Send/Receive).

So,

I believe that I have found a workaround to this, and it includes using
Outlook rules... I found an example on the MSDN called Launcher.dll
and addToPaB.dll (which will add the sender of the incoming message to
the users personal address book). I changed the code to run a batch
file that will run "pause", so this way for each incoming message I
should get a window that says "pause". After installing this custom
action rule I pressed send/receive on my outlook and got over 30
windows in my windows explorer bar. (Then I had to go to sleep because
I had work the next day)

So does anybody know for a fact that an outlook rule shall be run on
"every single" incoming message? regardless of what other rules run on
the same folder.... My intuition tells me that all rules run on all
messages in a folder.. even if rule A moves a message to another
folder. I believe that outlook gets the entry ID for each message and
then runs each rule on that entry ID, and if the message is moved
somewhere else, the entry ID is still the same, but the "location"
property is just different.

Thanks,
John Stratoudakis
Will post my findings as soon as I have results available
 
T

Thomas Quester

John,

If you look at IMAPIAdviseSink::OnNotify, there is a cNotif, telling how
many notifications are inside this single event.

ULONG OnNotify(
ULONG cNotif,
LPNOTIFICATION lpNotifications
);

On receiving the notification, clients must iterate through all
notifications and process them one-by-one. Some store providers have a
limited mesage queue, and may delete events from the queue, for example
clients may receive a TALBE_RELAD event if the store provider have had to
combine all table events into a single event. I think displaying dialogs in
event processing might be a bad idea if all event handlers are in the same
thread since this may block the store provider from firing more events.
Rules in Outlook should be based on IMAPIAdvise::OnNotify.

A simple and effective method for processing all messages is to tag all
messages which haven processed, if you have processed a message, add a user
defined property with any value (or write the entry ID of processed elements
into some external data file). On the next run, use a restriction to find
all elements which have the tag not set and iterate on all unprocessed
messages. In an Exchange or similar environments, tagging is the only way to
process all incomming messages, because the server is receiving e-mails also
if the client is not running.

The EntryID of an element is the same if an element is moved within the same
store provider, the Parent Entry ID will change.

Thomas Quester
www.olfolders.de
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top