右键单击日历并运行功能区操作是否可以获得所选日历日期的方式与获取当前mailItem或appointmentItem的方式相同?
功能区XML:
<contextMenu idMso="ContextMenuCalendarView">
<menu id="CallenderMenu" label="Actions">
<button id="NewDiaryEvent" label="Create new" onAction="CreateCallenderItem_click" />
</menu>
</contextMenu>
C#:
public void CreateCallenderItem_click(IRibbonControl control)
{
// Get selected calendar date
}
答案 0 :(得分:4)
Dmitry是正确的,但这里是我用来获取您所选区域的开始和结束日期的代码示例:
public void CreateCallenderItem_click(IRibbonControl control)
{
// Get selected calendar date
Outlook.Application application = new Outlook.Application();
Outlook.Explorer explorer = application.ActiveExplorer();
Outlook.Folder folder = explorer.CurrentFolder as Outlook.Folder;
Outlook.View view = explorer.CurrentView as Outlook.View;
if (view.ViewType == Outlook.OlViewType.olCalendarView)
{
Outlook.CalendarView calView = view as Outlook.CalendarView;
DateTime calDateStart = calView.SelectedStartTime;
DateTime calDateEnd = calView.SelectedEndTime;
// Do stuff with dates.
}
}
我希望这会对你有所帮助。
答案 1 :(得分:1)
阅读Application.ActiveExplorer.CuurentFolder.CurrentView属性,检查它是否是CalendarView,然后读取CalendarView.SelectedStartTime属性。