Article ID: 279502 - Last Review: February 26, 2004 - Revision: 4.5 OL2000: ItemRemove Event Does Not Run in Some ScenariosThis article was previously published under Q279502 On This PageSYMPTOMS
You use the ItemRemove event in an Outlook solution, but the event does not run.
CAUSE
The event is designed to parallel the MAPI function ROW_DELETE, but there are scenarios where MAPI issues a TABLE_CHANGED notification instead of a ROW_DELETE notification when items are deleted. Either of the following scenarios prevents the ItemRemove event running:
WORKAROUND
Use one of the following methods to work around the problem.
Method 1To work around the limitation of the ItemRemove event not running when the last item in a .pst folder is deleted, you can use the FolderChange event to detect when a change has been made to a folder, and then check to see if the number of items in the folder is zero. If so, this means the last item in the folder was deleted. For example, the following Outlook Visual Basic for Applications code monitors the default Contacts folder, and displays a message when the last contact is deleted.Method 2Depending on your solution's needs, implement your own custom algorithm to determine when items have been deleted. You may want to implement the ItemRemove event to handle most deletions, and then run some other code on a timer to trap deletions that are not detected by the ItemRemove event.Method 3If you are using Microsoft Exchange Server 5.5 Service Pack 1 (SP1) or later, you can implement an Exchange Server Scripting Agent script if the folder is located in an Exchange Server public folder or mailbox. In the script, you can implement the OnMessageDeleted event. However, you must use the Collaboration Data Objects (CDO) object model in the server script, and not the Outlook object model; therefore, this approach may not be feasible for your solution. For more information about SUGGEST.EXE, click the following article number to view the article in the Microsoft Knowledge Base:192339
(http://support.microsoft.com/kb/192339/
)
SUGGEST.EXE is Microsoft Exchange Server Custom Agent
For additional information about how to use the OnMessageDeleted event in a server script, click the article number below to view the article in the Microsoft Knowledge Base: 231160
(http://support.microsoft.com/kb/231160/EN-US/
)
HOWTO: Relate a Deleted Message Using Folder_OnMessageDeleted
IMPORTANT: Exchange Server 5.x scripts do not scale well if they are applied to multiple mailboxes. Performance varies greatly depending on many factors, but do not consider applying scripts to more than about 10 to 20 mailboxes.
STATUSMicrosoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article. MORE INFORMATION
This same type of limitation affects the ItemAdd event. For additional information, click the article number below
to view the article in the Microsoft Knowledge Base:
249156
(http://support.microsoft.com/kb/249156/EN-US/
)
OL2000: ItemAdd Event Doesn't Fire in Some Scenarios
REFERENCESFor additional information about available resources and answersto commonly asked questions about Microsoft Outlook solutions, click the article number below
to view the article in the Microsoft Knowledge Base:
146636
(http://support.microsoft.com/kb/146636/EN-US/
)
OL2000: Questions About Custom Forms and Outlook Solutions
| Article Translations
|

Back to the top
