Bind custom extended property for existing appointment using EWS managed API 2.0

送分小仙女□ 提交于 2019-12-02 00:48:48
Jürgen Hoffmann

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
    }
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!