首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Outlook筛选器项目-获取周范围内的所有定期约会

Outlook筛选器项目-获取周范围内的所有定期约会
EN

Stack Overflow用户
提问于 2011-11-08 06:37:18
回答 1查看 5.4K关注 0票数 4

我正在尝试将outlook中的所有约会都显示在周范围内,但未显示重复出现的约会。

代码如下:

代码语言:javascript
复制
    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中显示的某周范围内的所有定期约会?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-11-08 07:44:33

您必须使用recurrence pattern将以下代码放入您的循环中:

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

有关更多信息,请参阅this

票数 5
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/8043633

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档