I want to make unique appointment to put in database using custom extended properties. I find all appointments using FindAppointments():
var appointments = _serv
see my answer at this post: Exchange Webservice Managed API - Find items by extended properties I think your problems are pretty simular to this. The "FindItems" methods doesnt load any custom property. thats the reason why
if (appointment.ExtendedProperties.Count <= 0)
is always true, even if the appointment already has your custom property. Next Thing is, that i recommend you to create your Extended property in the DefaultExtendedPropertySet.PublicStrings instead of creating an own guid. I tried own guids as well and never got it working correct.
Try it like this:
ExtendedPropertyDefinition def = new ExtendedPropertyDefinition(DefaultExtendedPropertySet.PublicStrings, "RateTheMeetingId", MapiPropertyType.Integer);
so finally your code should look like this:
var appointments = _service.FindAppointments(WellKnownFolderName.Calendar, calendarView);
ExtendedPropertyDefinition def = new ExtendedPropertyDefinition(DefaultExtendedPropertySet.PublicStrings, "RateTheMeetingId", MapiPropertyType.Integer);
PropertySet propset = new PropertySet(PropertySet.IdOnly);
propset.Add(def);
foreach (var appointment in appointments)
{
//appointment should already be binded, now load it
appointment.Load(propset);
object value = null;
if (item.TryGetProperty(def, out value))
{
//Do something
}
else
{
//Add Property
}
}