• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 282
  • Last Modified:

Catch an Item delete


I'm customizing the appointment form.
How can I capture the DELETE event of
an existing form (when the user clicks
the delete button and confirms) using vb / vbscript?
1 Solution
yronnenAuthor Commented:
Edited text of question.
yronnenAuthor Commented:
Adjusted points to 200
yronnenAuthor Commented:
Adjusted points to 250
Free tool for managing users' photos in Office 365

Easily upload multiple users’ photos to Office 365. Manage them with an intuitive GUI and use handy built-in cropping and resizing options. Link photos with users based on Azure AD attributes. Free tool!

As of my knowledge: you cannot capture this event in Outlook. Below follows MSDN explanation:
ItemRemove Event

Occurs when an item is deleted from the specified collection. This event is not available in VBScript.


Sub object_ItemRemove()

object An expression that evaluates to an Items collection object

As you can see this event is not available in VBSCRIPT. However you CAN capture it using public folders. There exists Folder_OnMessageDeleted function. Fired (by MS Exchange Event Service) - guess when ? - when message is deleted. Details: http://www.cdolive.com/agent3.htm
yronnenAuthor Commented:
your answer requires that I install CDO on each of the outlook clients.

The problem is that most of the time these computers are not connected to the network (laptops).

I've tried using the item_remove by:
1. using getobject from my com object to get a reference to the existing outlook application.
2. Since I'm customizing an appointment form I've typed: Set OlItems = objOLApp.GetNamespace("MAPI").GetDefaultFolder(olFolderCalendar).Items
and declared OlItems as items with events - so now I have a pointer to the items collection.

The problem is that the events (especially the remove event) are not working.
You have writtent that you declared Items object with events. You should use a single item (i.e. AppointmentItem) object with events.

Also I've noticed that when item is deleted Write event occurs. It may help - catch this event, and after a while check if the item still exists in collection. if it doesn't it probably was deleted.
yronnenAuthor Commented:
Sorry, but that's not a good one. I've tried this method before, and the problem is that I can't use the find method using the EntryID as a search criteria. Meaning - you cannot search an outlook item using it's unique key...

So I MUST catch a delete event when it happens and know what was deleted.
There is no surefire solution to your issue in the current Outlook/Exchange environment, for the reasons detailed in previous comments.

Exchange 2000 will, for the first time, introduce a synchronous server-based event for catching item deletions before they happen -- when it is still possible to get information out of the item.

Workarounds in the current climate center on monitoring the Deleted Items folder for new items. (This, of course, misses anything deleted with Shift+Delete.)

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now