代码之家  ›  专栏  ›  技术社区  ›  RobD

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

  •  0
  • RobD  · 技术社区  · 6 年前

    我用它来添加一个日历条目到一个共享日历(它不会将它添加到共享日历),它也不会设置开始和结束时间,它只是将条目添加为一个全天事件。这可能吗,我一直在用这个:

    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 回复  |  直到 6 年前