最近开发一个outlook addin,要用到outllook calendar,其他有一个功能是新建立一个约会或会议时,这些约会或会议可能有同期性,因此在建立一个约会以后,则设定了固定周期的约会就会自动出现。

由于以前没有做过类似的开发,只是参照了MSDN写了一个创建约会的程序,但是怎么去让它循环这个问题,并不清楚。再看了Outlook.AppointmentItem这个类,发现里面有一个RecurrenceState属性,看上去只有它与Recurrence Appointment有关,但是再认真一看,这个是一个只读属性,不能设的,因此一时陷入困境,不知道怎么去办。

后来上网上查了一下,感觉也没什么结果。

后来,就随便试了一下,程序如下,就可以解决了。希望对大家有所帮助。

private void CreateAppointment()
        {
            Outlook.AppointmentItem pAppointmentitem = null;
            Redemption.SafeAppointmentItem rAppointmentItem = null;
            rAppointmentItem = new Redemption.SafeAppointmentItemClass();
            Outlook.RecurrencePattern iRec = null;
            pAppointmentitem=(Outlook.AppointmentItem) this.OutlookApplication.CreateItem(Outlook.OlItemType.olAppointmentItem);
                
            rAppointmentItem.Item = pAppointmentitem;
                
            pAppointmentitem.Subject = "Test Daily";
                
            pAppointmentitem.Start = DateTime.Parse("2007-12-16 08:00:00.000");

            pAppointmentitem.End = DateTime.Parse("2007-12-16 08:00:00.000").AddMinutes(30);

            pAppointmentitem.AllDayEvent = false;

            pAppointmentitem.Sensitivity = Outlook.OlSensitivity.olPrivate;

             rAppointmentItem.RTFBody = "Test outlook appointment";

            pAppointmentitem.ReminderSet = true;
            pAppointmentitem.ReminderMinutesBeforeStart = 5;

            pAppointmentitem.ReminderPlaySound = false;

           iRec = pAppointmentitem.GetRecurrencePattern();

            iRec.Duration = 30;

            iRec.StartTime = DateTime.Parse("2007-12-16 08:00:00.000");

            iRec.RecurrenceType = Outlook.OlRecurrenceType.olRecursDaily;
            iRec.Interval = 1;
            iRec.NoEndDate = false;
            iRec.PatternEndDate = DateTime.Parse("2007-12-16 08:00:00.000").AddDays(10);
            iRec.Occurrences = 10;
            iRec.PatternStartDate = DateTime.Parse("2007-12-16 08:00:00.000");
                       

            pAppointmentitem.Categories = "";
                    

            pAppointmentitem.Save();

        }

相关文章:

  • 2021-05-31
  • 2021-10-26
  • 2021-06-29
  • 2021-05-11
  • 2021-05-10
  • 2021-08-04
  • 2022-12-23
  • 2021-07-26
猜你喜欢
  • 2021-06-19
  • 2022-01-28
  • 2022-02-27
  • 2022-12-23
  • 2021-06-22
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案