Exchange web services: why is ItemId not constant? [continued]

前端 未结 1 1301
走了就别回头了
走了就别回头了 2020-12-09 20:54

as some others have discuss this problem before (e.g., Exchange web services: why is ItemId not constant?), I want to talk about the solution, I have done what people have s

相关标签:
1条回答
  • 2020-12-09 21:28

    I have found the solution to my problem after sometime of trying and searching .

    private static readonly PropertyDefinitionBase AppointementIdPropertyDefinition = new ExtendedPropertyDefinition(DefaultExtendedPropertySet.PublicStrings, "AppointmentID", MapiPropertyType.String);
    public static PropertySet PropertySet = new PropertySet(BasePropertySet.FirstClassProperties, AppointementIdPropertyDefinition);
    
    
    //Setting the property for the appointment 
     public static void SetGuidForAppointement(Appointment appointment)
    {
        try
        {
            appointment.SetExtendedProperty((ExtendedPropertyDefinition)AppointementIdPropertyDefinition, Guid.NewGuid().ToString());
            appointment.Update(ConflictResolutionMode.AlwaysOverwrite, SendInvitationsOrCancellationsMode.SendToNone);
        }
        catch (Exception ex)
        {
            // logging the exception
        }
    }
    
    //Getting the property for the appointment
     public static string GetGuidForAppointement(Appointment appointment)
    {
        var result = "";
        try
        {
            appointment.Load(PropertySet);
            foreach (var extendedProperty in appointment.ExtendedProperties)
            {
                if (extendedProperty.PropertyDefinition.Name == "AppointmentID")
                {
                    result = extendedProperty.Value.ToString();
                }
            }
        }
        catch (Exception ex)
        {
         // logging the exception
        }
        return result;
    } 
    
    0 讨论(0)
提交回复
热议问题