日历中的每日定期约会在Outlook 2013中存储为每周定期约会

时间:2015-09-28 08:51:16

标签: c# outlook add-in

这是我的代码:

Outlook.AppointmentItem oMeet;

Meeting Meet;

Hashtable htrecc = GetReccuranceTable(strRec);

  if (Meet.recctype.Substring(0, 3) == "day")

  {

     oMeet.GetRecurrencePattern().RecurrenceType = OlRecurrenceType.olRecursDaily;

     oMeet.GetRecurrencePattern().Interval = Convert.ToInt32(htrecc["Interval"]);

     if (string.Equals("no", htrecc["Occurence"]))

         oMeet.GetRecurrencePattern().NoEndDate = true;

     else

          if (!string.IsNullOrEmpty(Convert.ToString(htrecc["Occurence"])))

              oMeet.GetRecurrencePattern().Occurrences = Convert.ToInt32(htrecc["Occurence"]);

          else

              oMeet.GetRecurrencePattern().PatternEndDate = Meet.EndTime;

    }

如果我在任何地方出错,请建议,因为每当我尝试将日常约会插入日历时,它会被转换为日历上的每周约会

1 个答案:

答案 0 :(得分:0)

我建议从打破属性和方法调用链开始,然后在不同的代码行上声明它们。每次在代码中调用GetRecurrencePattern方法时,都会得到一个新实例。

当您使用定期约会项目时,您应该释放任何先前的引用,在访问或修改项目之前获取对定期约会项目的新引用,并在完成并保存更改后立即释放这些引用。此实践适用于重复出现的AppointmentItem对象,以及任何Exception或RecurrencePattern对象。若要在Visual Basic for Applications(VBA)或Visual Basic中释放引用,请将该现有对象设置为Nothing。在C#中,显式释放该对象的内存。完成使用后,使用System.Runtime.InteropServices.Marshal.ReleaseComObject释放Outlook对象。然后在Visual Basic中将变量设置为Nothing(C#中为null)以释放对该对象的引用。在Systematically Releasing Objects article中详细了解相关内容。

请注意,即使在您发布引用并尝试获取新引用之后,如果仍存在由其他加载项或Outlook保存的活动引用,则上述对象之一仍然存在,您的新引用仍将指向对象的过时副本。因此,请务必在完成定期约会后立即发布参考文献。

相关问题