Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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 suggested by stamping the Guid as an extended property, For me this solution is kind of nice (although I do not know how to make it work with the occurrences) but only as long as the application works, once the application restarts the extended properties of the items disappear, so my problem now, is “How to stamp the extended property on the EWS item and make it constantly there?” This is the code of updating the calendar items (appointments)

public void SetGuidForAppointement(Appointment appointment)
{         
appointment.SetExtendedProperty((ExtendedPropertyDefinition)_appointementIdPropertyDefinition, Guid.NewGuid().ToString());
appointment.Update(ConflictResolutionMode.AlwaysOverwrite, SendInvitationsOrCancellationsMode.SendToNone);
}

And these are the properties definition needed above.

_appointementIdPropertyDefinition = new ExtendedPropertyDefinition(DefaultExtendedPropertySet.Appointment, "AppointmentID", MapiPropertyType.String);
            _propertyDefinitionBases = new PropertyDefinitionBase[] { _appointementIdPropertyDefinition, ItemSchema.ParentFolderId, AppointmentSchema.Start, AppointmentSchema.End, 
AppointmentSchema.LegacyFreeBusyStatus, AppointmentSchema.Organizer };
            PropertySet = new PropertySet(BasePropertySet.FirstClassProperties, _propertyDefinitionBases);

So if anyone has done this before could he/she provide me with an example that keeps the extended property stamped on the item even if the application exited. Thanks

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
288 views
Welcome To Ask or Share your Answers For Others

1 Answer

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...