tuncali

Hi all,

I want to prevent users to delete appoinment items wihthout sending messsage to other meeting participants. How can I catch "item delete event" under calendar folder if an appoinment deleted or canceled If its possible, I want to hide standard message box of Outlook and send notification to all other participants.

I am using VSTO & Outlook2003

thanks


Re: Visual Studio Tools for Office Item_delete event of appoinment

X4U

Hello Tuncalli,

the delete event is a well known problem in Outlook !

I have a small proof-of-concept code on my site:

http://www.x4u.de/Outlook/Codesnippets/tabid/61/Default.aspx

Have a look at the ItemTrapper Sample - traps the delete event of the current selected Item in the Calendar folder.

Hope this helps,

greets, Helmut






Re: Visual Studio Tools for Office Item_delete event of appoinment

Sue Mosher - Outlook MVP

Helmut, does your sample also handle the case of the user deleting from the right-click context menu In that scenario, the item isn't necessarily in ActiveExplorer.Selection. Thanks.




Re: Visual Studio Tools for Office Item_delete event of appoinment

X4U

Hello Sue,

I don't think so, because it is programmed only for selected Items.

But - a bad Trick would be to let the user delete the Item, then it goes to the deleted folder. Then maybe you can restore it on the fly.

However - doesn't work for Shift-Delete.

But here you can use the Key-Handler - you have a sample for this on your site.

Should I investigate a little bit time in this problem

Greets, Helmut






Re: Visual Studio Tools for Office Item_delete event of appoinment

Sue Mosher - Outlook MVP

I don't understand how a key handler could tell you know what item was deleted.

The real solution is to move to Outlook 2007. Smile




Re: Visual Studio Tools for Office Item_delete event of appoinment

X4U

Hi Sue - yes you are right to move to OL2007.

The sample I have written prevents the delete of an selected Item.

But you asked me how to prevent the delete of a non selected Item...

And this is just an Idea:

Whenever you delete an Item e.g. press delete or right-click

It goes to the trash folder.

From here you can move it back to the calendarfolder.

When you press Shift-delete - you can't catch it, because it won't go to the trash folder.

But here you can intercept the Shift-Del key to do something before the delete action.

Suppress it for example.

As you know:

Only proof of concept - haven't tested.

Greets, Helmut






Re: Visual Studio Tools for Office Item_delete event of appoinment

X4U

Hi Sue,

another Idea:

Wouldn't it be possible to use the API function "WindowFromPoint" to get the Window under the Mousepinter

Maybe you can get the Right-clicked object from here.

Not sure if this works, because the "Supergrid" doesn't expose much information about it's objects

Greets, Helmut






Re: Visual Studio Tools for Office Item_delete event of appoinment

Sue Mosher - Outlook MVP

But what if you didn't want to suppress the delete action, but process it in some way (as in synchronizing with another data source) I don't think the key intercept would help in that scenario, because it wouldn't tell you what item is being removed. And I don't think that's available from Windows API.

The only solution I know that handles all scenarios is to maintain a separate record of the data for comparison -- a "before" snapshot.




Re: Visual Studio Tools for Office Item_delete event of appoinment

X4U

Let's say:

The next Item in Trashfolder was a deleted one.

Use the TrashFolder.Items.Add event. (I think it's also in the sample)

Normally if you want to Sync with external Data you will have some additional Info like a Guid.

Then you can update your Database - and commit the delete or move it back to the Calendar.

However, Intercepting the Shift-Delete prevents deleting Items without passing the Trashfolder.

When it goes to the Trash - I can check it and sync it.

Greets, Helmut






Re: Visual Studio Tools for Office Item_delete event of appoinment

Sue Mosher - Outlook MVP

Blocking Shift+Delete would certainly be a possibility -- if removing that functionality is acceptable to the customer.

Remember that Items.ItemAdd won't fire for large additions of deleted items, so you might have to depend on ItemRemove and then go look to see what items are new in Deleted Items.




Re: Visual Studio Tools for Office Item_delete event of appoinment

X4U

Yes - I know. The more then 16 Items + Problem.

My answer would be:

Check all Items in the deleted Items folder whenever you get such an event.

So the Sync maybe is not in realtime.

Or use a timer to poll the deleted items folder.

Anyway - any of this solutions we discussed is a hack.

Greets, Helmut