如何在使用C#VSTO创建约会时找到下一个可用时间

时间:2015-02-10 16:06:03

标签: c# vsto outlook-addin

我在C#中编写了以下代码,与1位与会者(和我)一起创建了一个新约会。但是开始时间不会自动默认为下一个可用的空闲时间。

AppointmentItem newAppointment = Globals.ThisAddIn.Application.CreateItem(OlItemType.olAppointmentItem);
newAppointment.MeetingStatus = OlMeetingStatus.olMeeting;

Recipients recipients = newAppointment.Recipients;
Recipient readyByRecipient = null;
readyByRecipient = recipients.Add(emailAddress);
readyByRecipient.Type = (int)OlMeetingRecipientType.olRequired;
recipients.ResolveAll();
newAppointment.Display();

Marshal.ReleaseComObject(readyByRecipient);
Marshal.ReleaseComObject(recipients);
Marshal.ReleaseComObject(newAppointment);

有人可以告诉我如何将约会开始时间默认为所有与会者的下一个可用空闲时间吗?

或者如何在所有与会者的下一个可用空闲时间以编程方式计算出来?

1 个答案:

答案 0 :(得分:2)

使用Recipient.FreeBusy(或AddressEntry.GetFreebusy)查看可用的时隙。您可以为当前用户(Application.Session.CurrentUser)和/或约会与会者执行此操作。