Items collection event handlers

M

Mark J. McGinty

(Sorry for posting the same basic questions that I already posted to another
group, but days have gone by, and this one seems more relevant.)

I'm processing contact item events by declaring a variable as such:

Public WithEvents m_ContactItems As Outlook.Items

And initializing it like this:

Set m_ContactItems =
Outlook.Application.GetNamespace("MAPI").GetDefaultFolder(olFolderContacts).Items

That all works fine, except that as I just went to add an ItemRemove
handler, I saw that, unlike ItemAdd and ItemChange, ItemRemove does not
receive an Item parameter when it's called. What gives?

How do I determine which item is being deleted?

Also, ItemChange passes the newly changed item to the handler, is there any
way to get the former values from within this event handler?

tia,
Mark
 
K

Ken Slovak - [MVP - Outlook]

You can trap ItemAdd in the Deleted Items folder but that won't help with
items deleted using Shift+Delete, which bypasses Deleted Items. The only way
other than that is to monitor the entire Items collection and see what's
missing after ItemRemove fires.

You cannot get previous values of an item's properties in ItemChange. You
would have to save the previous values and compare.
 

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