一種方法是使用SilverNinja建議的唯一ID,因爲他說這不是永久ID,並且一旦約會移動到不同的文件夾就可以更改它(如果它已經刪除例如)。
來處理這個問題的方法是創建一個擴展屬性,把GUID的任命,並且它不會改變,除非你做從另一個約會複印件(畢竟它只是一個屬性)
我有它在C#中,但我相信這是很容易轉換到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;
}
謝謝你生病嘗試一下 –
我有一個完全不同的問題,但你的代碼幫我解決它無論如何:如何避免更新時向相關人員發送通知。這顯然是通過在Update()中指定sendInvitationsOrcancellationsMode參數來完成的。所以thx。 :) –