簡體   English   中英

Outlook篩選項 - 獲取一周范圍內的所有定期約會

[英]Outlook Filter Items - Get all recurring appointments in a week range

我試圖在周范圍內獲得所有約會,但重復出現的約會沒有出現。

這是代碼:

    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中顯示的所有定期約會一周?

你必須使用重復模式把它放在你的循環中:

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

有關詳細信息,請參閱

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM