Outlook 加载项 VSTO DASL 问题

发布于 2024-08-04 04:36:51 字数 1250 浏览 1 评论 0原文

在我的 Outlook 插件中,我希望能够筛选具有以下条件的约会的默认日历:

  1. 全天事件 = true
  2. 提醒集 = true

我已经弄清楚如何使用 DASL 来搜索这些项目,但是如何我如何让日历视图显示这些过滤结果?

这是我到目前为止的代码:

internal class MyAppointment : Appointment
{
    [OutlookItemProperty("urn:schemas:calendar:dtstart")]
    public DateTime Start { get { return Item.Start; } }

    [OutlookItemProperty("urn:schemas:calendar:dtend")]
    public DateTime End { get { return Item.End; } }

    public bool ReminderSet { get { return Item.ReminderSet; } }

    public bool AllDayEvent { get { return Item.AllDayEvent; } }
}


void btnFix_Click(Microsoft.Office.Core.CommandBarButton Ctrl, ref bool CancelDefault)
{
    Outlook.Folder folder = (Outlook.Folder)Globals.ThisAddIn.Application.Session.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderCalendar);

    var appts = from item in folder.Items.AsQueryable<MyAppointment>()
                where item.Start >= DateTime.Now
                && item.End <= DateTime.Now.AddMonths(1)
                && item.ReminderSet
                && item.AllDayEvent
                select item.Item;

    // bind to Calendar view???
}

我现在有一个约会集合。我如何获取日历来显示它们?

In my Outlook Add-in I want to be able to filter my default calendar for appointments that have the following criteria:

  1. all-day events = true
  2. reminders set = true

I have figured out how to use DASL to search for those items, but how do I get the calendar view to show those filtered results?

Here is the code I have so far:

internal class MyAppointment : Appointment
{
    [OutlookItemProperty("urn:schemas:calendar:dtstart")]
    public DateTime Start { get { return Item.Start; } }

    [OutlookItemProperty("urn:schemas:calendar:dtend")]
    public DateTime End { get { return Item.End; } }

    public bool ReminderSet { get { return Item.ReminderSet; } }

    public bool AllDayEvent { get { return Item.AllDayEvent; } }
}


void btnFix_Click(Microsoft.Office.Core.CommandBarButton Ctrl, ref bool CancelDefault)
{
    Outlook.Folder folder = (Outlook.Folder)Globals.ThisAddIn.Application.Session.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderCalendar);

    var appts = from item in folder.Items.AsQueryable<MyAppointment>()
                where item.Start >= DateTime.Now
                && item.End <= DateTime.Now.AddMonths(1)
                && item.ReminderSet
                && item.AllDayEvent
                select item.Item;

    // bind to Calendar view???
}

I now have a collection of Appointments. How do I get the calendar to show them?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

漆黑的白昼 2024-08-11 04:36:51

如果有人需要的话,答案是:。

  1. 将查询构建为字符串过滤器。
  2. 将其作为日历的过滤器应用
    文件夹。

    Outlook.CalendarView 视图 = (Outlook.CalendarView)Application.ActiveExplorer().CurrentView;
    过滤器 = "\"urn:schemas:calendar:alldayevent\" = 1 AND \"http:// schemas.microsoft.com/mapi/id/{00062008-0000-0000-C000-000000000046}/8503000b\" = 1";

    view.Filter = 过滤器;
    view.Apply();

The answer should anyone require it:.

  1. Build the query as a string filter.
  2. Apply it as a filter to the Calendar
    folder.

    Outlook.CalendarView view = (Outlook.CalendarView)Application.ActiveExplorer().CurrentView;
    filter = "\"urn:schemas:calendar:alldayevent\" = 1 AND \"http://schemas.microsoft.com/mapi/id/{00062008-0000-0000-C000-000000000046}/8503000b\" = 1";

    view.Filter = filter;
    view.Apply();

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文