OL97: Cannot Programmatically Determine When Item Is Deleted (278746)



The information in this article applies to:

  • Microsoft Outlook 97

This article was previously published under Q278746

SYMPTOMS

When you create a custom solution by using Outlook, if you need to determine when an item is deleted from a folder, there may seem to be no way to do so.

CAUSE

This issue can occur because the Outlook object model does not contain a Delete event. This is mainly due to architectural limitations. The underlying MAPI-based stores only send a notification that an item has been deleted after the deletion has occurred. Therefore there is no direct, consistent way for Outlook to obtain a reference to the item before the item is deleted.

WORKAROUND

To work around this issue, use one of the following methods:

Method 1

If you are using Microsoft Exchange Server 5.5 Service Pack 1 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, so this approach may not be feasible for your solution. You can obtain additional information about the Exchange Server Scripting Agent from the following Microsoft Web site: 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 HOWTO: Relate a Deleted Message Using Folder_OnMessageDeleted

IMPORTANT: Microsoft Exchange Server 5.0 and 5.5 scripts do not scale well if they are applied to multiple mailboxes. Performance varies greatly depending on many factors, but you should not consider applying scripts to more than about 10 to 20 mailboxes.

Method 2

If your solution is to try to keep data in an Outlook folder synchronized with external data, create a stand-alone application that periodically runs and checks the folder to see if items have been deleted.

Method 3

The Microsoft Outlook 2000 Object model contains an ItemRemove event, so you may want to consider upgrading to Outlook 2000. However, the Outlook 2000 implementation of the ItemRemove event does not return the item that has been deleted, so you still need to create an algorithm to determine which item has been deleted.

REFERENCES

For additional information about creating solutions with Outlook, click the article numbers below to view the articles in the Microsoft Knowledge Base:

166368 OL97: Resources for Custom Forms and Programming

170783 OL97: Questions About Customizing or Programming Outlook


Modification Type:MinorLast Reviewed:3/1/2004
Keywords:kbprb KB278746