添加Outlook日历条目时,无法设置开始时间和结束时间

时间:2018-11-07 20:06:15

标签: c# outlook

我正在使用此方法将日历项添加到共享日历(不会将其添加到共享日历),它也没有设置开始和结束时间,只是将该项添加为全天活动。这可能吗,我一直在使用它:

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);
    }
}

0 个答案:

没有答案