I'm creating an Outlook addin that needs to trigger when the attendees of a meeting are changed. The problem I'm encountering is that the PropertyChange event of an Appointment item is firing way too much and because of that I can't get the exact amount of attendees.
Here is some of the code I'm using:
private Outlook.AppointmentItem appointmentItem;
private void Inspectors_NewInspector(Outlook.Inspector inspector)
{
var item = inspector.CurrentItem as Outlook.AppointmentItem;
if (item != null)
{
appointmentItem = item;
temp = inspector;
visible = false;
appointmentItem.PropertyChange += AppOnPropertyChange;
}
}
private void AppOnPropertyChange(string name)
{
if (name.Equals("RequiredAttendees"))
{
var test = appointmentItem.Recipients.Count;
}
}
The event is triggered way too many times, and thus "test" will get values between 1 (the sender is always an attendee) and the number of attendees. Also if you have lets say 3 attendees and you remove one, "test" will be 4 - 3 - 2 - 1.
Is there a way to figure out the exact number of attendees in an AppointmentItem?
Any help would be much appreciated.