【问题标题】:How to Update an Appointment from Exchange Web Service Managed API 2.0 in ASP.NET如何从 ASP.NET 中的 Exchange Web 服务托管 API 2.0 更新约会
【发布时间】:2012-12-21 16:44:40
【问题描述】:

我正在使用 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)

【问题讨论】:

    标签: asp.net exchange-server exchangewebservices


    【解决方案1】:

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

    ItemId id = appointment.Id;
    

    ItemId can change if the AppointmentItem is moved or copied

    【讨论】:

      【解决方案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;
      } 
      

      【讨论】:

      • 我遇到了一个完全不同的问题,但无论如何你的代码帮助我解决了这个问题:如何在更新约会时避免向参加者发送通知。这显然是通过在 Update() 中指定 sendInvitationsOrcancellationsMode 参数来完成的。所以谢谢。 :)
      猜你喜欢
      • 2011-11-17
      • 1970-01-01
      • 1970-01-01
      • 2020-09-19
      • 1970-01-01
      • 2011-02-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多