2012-12-20 36 views
1

iam。它工作正常。但也想更新現有的預約。 我讀到我需要約會ID來指定應該編輯哪個約會。但ID在哪裏?如何從ASP.NET中的Exchange Web服務託管API 2.0更新約會使用EWS託管API 2.0創建Appontment的Iam

下面是如何創建預約:

 '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) 

回答

2

一種方法是使用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; 
} 
+0

謝謝你生病嘗試一下 –

+1

我有一個完全不同的問題,但你的代碼幫我解決它無論如何:如何避免更新時向相關人員發送通知。這顯然是通過在Update()中指定sendInvitationsOrcancellationsMode參數來完成的。所以thx。 :) –

相關問題