1

我正在使用 EWS 托管 API 2.0 创建 Appontment。它工作正常。但也想更新现有约会。我读到我需要约会 ID 来指定应该编辑哪个约会。但是身份证在哪里?

这是我创建约会的方式:

        'Creates the Appointment
        Dim appointment As New EWS.Appointment(esb)
        appointment.Subject = txtThema.Text
        appointment.Body = txtBemerkung.Text
        appointment.Start = Von
        appointment.End = Bis
        appointment.Location = lbRaumInfo.Text

        'Adds the Attendees
        For i = 1 To emaillist.Length - 1
            appointment.RequiredAttendees.Add(emaillist(i))
        Next

        'Sending
        appointment.Save(EWS.SendInvitationsMode.SendToAllAndSaveCopy)
4

2 回答 2

2

AppointmentItem可以通过ItemSchema's Idproperty检索的临时唯一 ID 。它应该在保存后出现AppointmentItem

ItemId id = appointment.Id;

如果移动或复制,则ItemId可以更改AppointmentItem

于 2012-12-21T04:07:07.900 回答
2

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;
} 
于 2012-12-21T08:44:40.797 回答