5

すべての予定を週の範囲で見通しに入れようとしていますが、繰り返し発生する予定が表示されません。

コードは次のとおりです。

    var outlook = new Microsoft.Office.Interop.Outlook.Application();
    var calendar = outlook.Application.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar);
    calendar.Items.IncludeRecurrences = true;

    string filter = String.Format("[Start] >= {0} And [End] < {1}",
            DateTime.Now.Date.ToString("ddddd h:nn AMPM"),
            DateTime.Now.Date.AddDays(5).ToString("ddddd h:nn AMPM"));
    Outlook.AppointmentItem appointment;
    foreach (var item in calendar.Items.Restrict(filter))
    {
        appointment = item as Outlook.AppointmentItem;
        if (appointment != null)
        {
            MessageBox.Show(appointment.Start.ToString());
        }
    }

Outlookに1週間の範囲で表示されるすべての定期的な予定を取得するにはどうすればよいですか?

4

1 に答える 1

6

あなたは再発パターンを使用する必要が ありますこれをあなたのループの中に入れてください:

     if (item.IsRecurring)
        {
            Microsoft.Office.Interop.Outlook.RecurrencePattern rp = item.GetRecurrencePattern();
            DateTime first = new DateTime(2011, 11, 7, item.Start.Hour, item.Start.Minute, 0);
            DateTime last = new DateTime(2011, 12, 1);
            Microsoft.Office.Interop.Outlook.AppointmentItem recur = null;



            for (DateTime cur = first; cur <= last; cur = cur.AddDays(1))
            {
                    recur = rp.GetOccurrence(cur);
                    Console.WriteLine(cur.ToLongDateString());
            }
        }

詳細についてはこちら をご覧ください

于 2011-11-07T23:44:33.107 に答える