我正在使用此方法将日历项添加到共享日历(不会将其添加到共享日历),它也没有设置开始和结束时间,只是将该项添加为全天活动。这可能吗,我一直在使用它:
private void AddAppointment()
{
try
{
var AppOutlook = new Outlook.Application();
Outlook.AppointmentItem newAppointment = (Outlook.AppointmentItem)AppOutlook.CreateItem(Outlook.OlItemType.olAppointmentItem);
Microsoft.Office.Interop.Outlook.NameSpace oNS = AppOutlook.GetNamespace("MAPI");
Microsoft.Office.Interop.Outlook.Recipient oRep = null;
oRep = oNS.CreateRecipient("Someone Elses Calendar");
newAppointment.Start = DateTime.Now.AddHours(3);
newAppointment.End = DateTime.Now.AddHours(4);
newAppointment.Location = "remote";
newAppointment.Body = "Test Calendar Entry";
newAppointment.BusyStatus = Outlook.OlBusyStatus.olTentative;
newAppointment.AllDayEvent = true;
newAppointment.Subject = "Test Calendar Entry";
newAppointment.Save();
newAppointment.Display(true);
}
catch (Exception ex)
{
MessageBox.Show("The following error occurred: " + ex.Message);
}
}