olInboxItems_ItemAdd and exchange

  • Thread starter Thread starter Jane
  • Start date Start date
J

Jane

Hi,

I have an outlook macro that runs in ThisOutlookSession and uses
olInboxItems_ItemAdd(ByVal Item As Object) as its trigger. It takes a look
at new mails recieved and does some fancy stuff with them.

The problem I have is that when it is applied to outlook connected to
exchange, it works fine while outlook is opne and a new mail is recieved,
but for mails recieved while outlook is closed (i.e they all appear next
time it is opened) the routine does not trigger.

First, I'm not sure why this is - they still appear as new mails, and this
isnt true of outlook using pop3 accounts, and second how can I make it
trigger on the mails when outlook is opened ?

Help ! Thanks

Jane
 
Those items are already delivered into your Inbox by the time you open
Outlook. They were delivered by the server while Outlook was closed, so no
ItemAdd event will fire. What I usually do is in the startup code I check
for unread items in the Inbox and process those when the code starts up, any
items that come in after that are handled by the ItemAdd code.

I also usually add a user property or MAPI property to the unread items in
the Inbox so they don't get processed multiple times. A simple Boolean named
"Processed" serves that purpose.
 
Back
Top