展望外接程序 - 获取当前选择的日历日期 [英] Outlook Addin - Get current selected calendar date

查看:136
本文介绍了展望外接程序 - 获取当前选择的日历日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当右键单击在日历上并运行丝带行动有可能获得所选择的日历日期以同样的方式,你将获得当前的MailItem或appointmentItem?



丝带XML:

 <文本菜单idMso =ContextMenuCalendarView > 
<菜单ID =CallenderMenu标签=操作>
<按钮ID =NewDiaryEvent标签=创建新的的OnAction =CreateCallenderItem_click/>
< /菜单>
< /文本菜单>



C#:

 公共无效CreateCallenderItem_click(IRibbonControl控制)
{
//获取选定的日历日期
}


解决方案

德米特里是正确的,但这里是我用来获取您所选择的区域的开始和结束日期代码的例子:

 公共无效CreateCallenderItem_click(IRibbonControl控制)
{
//获取选定的日历日期
展望。应用程序=新Outlook.Application();
Outlook.Explorer探险= application.ActiveExplorer();
Outlook.Folder文件夹= explorer.CurrentFolder为Outlook.Folder;
Outlook.View视图= explorer.CurrentView为Outlook.View;

如果(view.ViewType == Outlook.OlViewType.olCalendarView)
{
Outlook.CalendarView calView =视图Outlook.CalendarView;
的DateTime calDateStart = calView.SelectedStartTime;
的DateTime calDateEnd = calView.SelectedEndTime;

//做的东西与日期。
}
}



我希望这可以帮助你多一些。


When right clicking on a calendar and running a ribbon action is it possible to get the selected calendar date the same way you would get the current mailItem or appointmentItem?

Ribbon 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
}

解决方案

Dmitry is correct but here is an example of the code I have used to get the start and finish date of the area you have selected:

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. 
    }
}

I hope this helps you some more.

这篇关于展望外接程序 - 获取当前选择的日历日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆