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

前端 未结 1 864
梦毁少年i
梦毁少年i 2021-01-22 07:44

I want to make unique appointment to put in database using custom extended properties. I find all appointments using FindAppointments():

var appointments = _serv         


        
1条回答
  •  执笔经年
    2021-01-22 08:22

    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
        }
    }
    

    0 讨论(0)
提交回复
热议问题