Outlook 加载项 VSTO DASL 问题
在我的 Outlook 插件中,我希望能够筛选具有以下条件的约会的默认日历:
- 全天事件 = true
- 提醒集 = 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:
- all-day events = true
- 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果有人需要的话,答案是:。
将其作为日历的过滤器应用
文件夹。
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:.
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();