How to Update an Appointment from Exchange Web Service Managed API 2.0 in ASP.NET

前端 未结 2 1666
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-16 07:50

iam using the EWS Managed API 2.0 to create an Appontment. It works fine. But want to Update an existing Appointment, too. I read that i need the appointment ID to specify

相关标签:
2条回答
  • 2021-01-16 08:29

    A way to do it, is to use the Unique ID as suggested by SilverNinja, and as he said that this is not permanent ID and it can be changed once the appointment is moved to different folder (like if it has been deleted for example).

    A way to deal with this problem is to create an extended property, and put guid for the appointment, and it wont change unless you made a copy from another appointment (after all it is just a property)

    I have it in C# , but I am sure it is pretty easy to convert to VB

    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)
  • 2021-01-16 08:43

    The temporary unique ID for the AppointmentItem can be retrieved via the ItemSchema's Id property. It should be present after saving the AppointmentItem.

    ItemId id = appointment.Id;
    

    The ItemId can change if the AppointmentItem is moved or copied.

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