tags:

views:

192

answers:

1

I need to perform some activity when an appointmentitem (or specifically a meeting) is saved.

What I want is once the user has filled in the info and clicks 'send', Outlook does it's stuff and my code executes once.

However what I'm finding, is that the Write event occurs multiple times - at least twice, sometimes more (eg in updates).

Where this is an issue for me, is that I have an object that needs to be updated before it's serialized, and I don't want to be doing the update and serialization multiple times.

Has anyone come across this issue, before and is there a better way to do this to use than appointmentitem.write?

+2  A: 

Hi, Sounds like you want it to capture the send event of the Appointment, or build a userproperty into the item that flag if it has been procesed and then check for that on each save.

Marcus

ADDED

       Outlook.ItemEvents_Event _apptEvents = (Outlook.ItemEvents_Event)ai;
    _apptEvents.Send += new Outlook.ItemEvents_SendEventHandler(_itemClass_ItemEvents_Event_Send); 
76mel
Ok I'll give that a go, but then how do I capture the send event? there's a Send() method, but I'm not sure how to capture the send event. Using the same code as capturing write event, for example, gives me a warning and error that it's using the method group, rather than the event:Error:Cannot assign to 'Send' because it is a 'method group'Warning: Ambiguity between method 'Microsoft.Office.Interop.Outlook._AppointmentItem.Send()' and non-method 'Microsoft.Office.Interop.Outlook.ItemEvents_10_Event.Send'. Using method group.
What version of outlook are you using ? the 2007 app send event http://msdn.microsoft.com/en-us/library/bb175136(v=office.12).aspx
76mel
Hi, yeah I use 2007 - I know the send event is there, but when I try to add a handler, it gives me the error as per above. Any ideas how I force it to use the event - the line of code that is the problem here is:ai.Send += new Microsoft.Office.Interop.Outlook.ItemEvents_10_SendEventHandler(ai_Send);Thanks, M
you need to cast, have added some code ..
76mel
Thanks Marcus, that works. Any ideas why write event gets fired off a number of times? Seems strange. Nevertheless, using send should get the job done. Cheers, Marcin.