Items.ItemAdd and NewMail Events

T

T OPry

Using the XP PIA with Outlook 2002 and 2003 with .Net

Trying to monitor new mail as it arrives in the inbox. Since the
Application.NewMail event does not fire with each addition, I monitor the
Items.ItemAdd event. This event will fire the FIRST time a new item is
received, but never again. The Application.NewMail never fires.

Tried using the native event handlers (creating the object WithEvents) as
well as using AddHandler, with same results.

Any ideas?
 
M

Martin Maat

T said:
Using the XP PIA with Outlook 2002 and 2003 with .Net

Trying to monitor new mail as it arrives in the inbox. Since the
Application.NewMail event does not fire with each addition, I monitor
the Items.ItemAdd event. This event will fire the FIRST time a new
item is received, but never again. The Application.NewMail never
fires.

I have similar experiences. I just scanned this newsgroup for an answer to
this problem and only found your question in 3438 messages going back to
2003. I won't be using events now because they just don't seem to work, on
demand scanning it will be. I would like to use events too though.

I am using interop wrappers from C#. Another thing that didn't work was the
Outlook 11 type library (Outlook 2003). Returned message dates were wrong
(all zero) and my application blew up with an older version of Outlook
(2000) even when I wasn't using any new interface. It was only after I
imported MSOUTL9.OLB of Outlook 2000 instead that things got better (also
with Outlook 2003!). The dates were OK now and nothing blew up anymore. They
really messed up the interface at some point after version 9. The only
upside of the newer type library was that it supported enumerators on
collections so I could use foreach instead of having to loop through the
1-based item set. Well that was nice, if only they hadn't made it absolutely
useless and unreliable in more essential areas. It cost me 3 days of agony.

So, still no events after the first one... Actually, you do get more than
one event if you drop several messages in a folder at once. Then an equal
number of events will be fired. The next batch will stay unnoticed though,
beit a single message or multiple ones that are dropped. As if the delegate
is eroneously garbage collected or something.


Redemption worked for me to by-pass the securitydialog, that was good (I
only have to read properties and extract messages from Outlook). Not being
able to use events sucks though. Is there a patch for this? It seems really
strange that we would be the only ones encountering this problem.

Any insights are most welcome. Is there anyone succesfully using folder
events (Items.ItemAdd) ? What type library did you import? What Outlook
version are you using? Is version 12 any better?

Regards, Martin.
 

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